Class: FormatOPML

Inherits:
ClWiki::CustomFormatter show all
Defined in:
lib/cl_wiki/format/format.opml.rb

Class Method Summary collapse

Class Method Details

.format_content(content, page) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/cl_wiki/format/format.opml.rb', line 13

def self.format_content(content, page)
  out = ['<NoWikiLinks>']
  content.grep(%r{<outline.*?>|</outline>}).each do |ln|
    title = ln.scan(/title=\"(.*?)\"/).compact
    html = ln.scan(/htmlUrl=\"(.*?)\"/).compact
    xml = ln.scan(/xmlUrl=\"(.*?)\"/).compact
    if html.empty? && xml.empty?
      if !title.empty?
        out << "<h4>#{title}</h4>"
        out << '<blockquote>'
      else
        out << '</blockquote>'
      end
    else
      out << "<a href='#{xml}'>[xml]</a> <a href='#{html}'>#{title}</a>"
    end
  end
  out.join("\n") + content
end

.match_reObject



9
10
11
# File 'lib/cl_wiki/format/format.opml.rb', line 9

def self.match_re
  %r{<opml.*?>.*?</opml>}m
end