Sha256: 1f0a4a70836ea7b97b2491de8e9610d6ce3e9f982c8393e7543896cb720d87b5
Contents?: true
Size: 1.09 KB
Versions: 1
Compression:
Stored size: 1.09 KB
Contents
module Caramelize module WikkaConverter # take an input stream and convert all wikka syntax to markdown syntax def to_markdown body body = body.dup body.gsub!(/(======)(.*?)(======)/ ) {|s| '# ' + $2 } #h1 body.gsub!(/(=====)(.*?)(=====)/) {|s| '## ' + $2 } #h2 body.gsub!(/(====)(.*?)(====)/) {|s| '### ' + $2 } #h3 body.gsub!(/(===)(.*?)(===)/) {|s| '#### ' + $2 } #h4 body.gsub!(/(\*\*)(.*?)(\*\*)/) {|s| '**' + $2 + '**' } #bold body.gsub!(/(\/\/)(.*?)(\/\/)/) {|s| '_' + $2 + '_' } #italic #str.gsub!(/(===)(.*?)(===)/) {|s| '`' + $2 + '`'} #code body.gsub!(/(__)(.*?)(__)/) {|s| '<u>' + $2 + '</u>'} #underline body.gsub!(/(.*?)(\n\t-)(.*?)/) {|s| $1 + '\n' + $3 } #list body.gsub!(/(\t-)(.*?)/) {|s| '*' + $2 } #list #str.gsub!(/(----)/) {|s| '~~~~'} #seperator body.gsub!(/(\[\[)(\w+)\s(.+?)(\]\])/, '[[\3|\2]]') #body.gsub!(/\[\[(\w+)\s(.+)\]\]/, ' [[\1 | \2]] ') # TODO more syntax conversion for links and images body end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caramelize-0.1.0 | lib/caramelize/wiki/wikka_converter.rb |