Skip to content

Instantly share code, notes, and snippets.

@masaki925
Created July 31, 2013 06:37
Show Gist options
  • Save masaki925/6119842 to your computer and use it in GitHub Desktop.
Save masaki925/6119842 to your computer and use it in GitHub Desktop.
convert from pukiwiki to textile
#!/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