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



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

def FormatOPML.format_content(content, page)
  out = ['<NoWikiLinks>']
  content.grep(/<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



7
8
9
# File 'lib/cl_wiki/format/format.opml.rb', line 7

def FormatOPML.match_re
  /<opml.*?>.*?<\/opml>/m
end