Sha256: fddf30bb3095866da76ece71fe186f21030f686fd5c4fc8eed70ae0c5782b2a6
Contents?: true
Size: 989 Bytes
Versions: 1
Compression:
Stored size: 989 Bytes
Contents
module Caramelize module Wikka2MarkdownConverter # take an input stream and convert all wikka syntax to markdown syntax def convert2markdown str str.gsub!(/(======)(.*?)(======)/ ) {|s| '# ' + $2 } #h1 str.gsub!(/(=====)(.*?)(=====)/) {|s| '## ' + $2 } #h2 str.gsub!(/(====)(.*?)(====)/) {|s| '### ' + $2 } #h3 str.gsub!(/(===)(.*?)(===)/) {|s| '#### ' + $2 } #h4 str.gsub!(/(\*\*)(.*?)(\*\*)/) {|s| '**' + $2 + '**' } #bold str.gsub!(/(\/\/)(.*?)(\/\/)/) {|s| '_' + $2 + '_' } #italic #str.gsub!(/(===)(.*?)(===)/) {|s| '`' + $2 + '`'} #code str.gsub!(/(__)(.*?)(__)/) {|s| '<u>' + $2 + '</u>'} #underline str.gsub!(/(.*?)(\n\t-)(.*?)/) {|s| $1 + '\n' + $3 } #list #str.gsub!(/(\t-)(.*?)/) {|s| '*' + $2 } #list #str.gsub!(/(----)/) {|s| '~~~~'} #seperator # TODO more syntax conversion for links and images str end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
caramelize-0.0.1 | lib/caramelize/wikka2markdown_converter.rb |