Created
July 31, 2013 06:37
-
-
Save masaki925/6119842 to your computer and use it in GitHub Desktop.
convert from pukiwiki to textile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/ruby | |
filename = ARGV.shift | |
File.open(filename, 'r').each_line do |line| | |
puts line.sub( | |
'#highlighter(sh){{' , '<pre>' ).gsub( | |
/^\}\}/ , '</pre>' ).gsub( | |
/^#contents/ , '{{toc}}' ).gsub( | |
/^#contents/ , '{{toc}}' ).gsub( | |
/^----/ , '' ).gsub( | |
/ \[#.+\]$/ , '' ).gsub( | |
/^\* (.*)/ , 'h2. \1' + "\n").gsub( | |
/^\*\* (.*)/ , 'h3. \1' + "\n").gsub( | |
/^\*\*\* (.*)/, 'h4. \1' + "\n").gsub( | |
/^- / , '* ' ).gsub( | |
/^-- / , '** ' ).gsub( | |
/^--- / , '*** ').gsub( | |
/^\+ / , '# ' ).gsub( | |
/^\+\+ / , '## ' ).gsub( | |
/^\+\+\+ / , '### ') | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment