Sha256: ea57595495bb8cbc69b14c31918073971caa5ded3debd7a4046d76998f865e6a

Contents?: true

Size: 408 Bytes

Versions: 1

Compression:

Stored size: 408 Bytes

Contents

#Encoding: UTF-8
module Caramelize
  class SwapWikiLinks

    # take an input stream and convert all wikka syntax to markdown syntax
    def run body
      body = body.dup

      body.gsub!(/\[\[(\S+)\|(.+?)\]\]/, '[[\2|\1]]')
      body.gsub!(/\[\[([\w\s-]*)\]\]/) do |s|
      	if $1
      		t = $1.dup
      		s = '[[' +t + "|"+ $1.gsub(' ', '_') + "]]"
      	end
      end

      body
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
caramelize-0.2.0 lib/caramelize/filters/swap_wiki_links.rb