class Caramelize::SwapWikiLinks
Public Class Methods
new(body)
click to toggle source
# File lib/caramelize/filters/swap_wiki_links.rb, line 3 def initialize(body) @body = body end
Public Instance Methods
run()
click to toggle source
take an input stream and convert all wikka syntax to markdown syntax
# File lib/caramelize/filters/swap_wiki_links.rb, line 8 def run migrated_body = @body.dup migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]/) { format_link($2, $1) } migrated_body.gsub!(/\[\[([\w\s\-\.]*)\]\]/) { format_link($1, $1.dup) } migrated_body end
Private Instance Methods
format_link(label, link)
click to toggle source
# File lib/caramelize/filters/swap_wiki_links.rb, line 19 def format_link(label, link) link.downcase! link.gsub!(' ', '_') link.gsub!(/\./, '') "[[#{label}|#{link}]]" end