class Caramelize::SwapWikiLinks

Public Class Methods

new(body) click to toggle source
# File lib/caramelize/filters/swap_wiki_links.rb, line 5
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 10
def run
  migrated_body = @body.dup

  migrated_body.gsub!(/\[\[(\S+)\|(.+?)\]\]/) { format_link(::Regexp.last_match(2), ::Regexp.last_match(1)) }
  migrated_body.gsub!(/\[\[([\w\s\-.]*)\]\]/) { format_link(::Regexp.last_match(1), ::Regexp.last_match(1).dup) }

  migrated_body
end

Private Instance Methods