aboutsummaryrefslogtreecommitdiff
path: root/tools/trac-wiki-to-markdown.rb
diff options
context:
space:
mode:
authorRob Austein <sra@hactrn.net>2021-02-14 01:35:10 +0000
committerRob Austein <sra@hactrn.net>2021-02-14 01:35:10 +0000
commit23bb68fe7e9cc8af176ff60b56e8a51a70f05a89 (patch)
tree27c87a0c157e6eb343518031c4c3afd1e95bc488 /tools/trac-wiki-to-markdown.rb
parentfa8b4d0e872d182ee878020fb1b066ce0da621ae (diff)
Now generating pages directly from sqlite3
Diffstat (limited to 'tools/trac-wiki-to-markdown.rb')
-rw-r--r--tools/trac-wiki-to-markdown.rb51
1 files changed, 0 insertions, 51 deletions
diff --git a/tools/trac-wiki-to-markdown.rb b/tools/trac-wiki-to-markdown.rb
deleted file mode 100644
index f7d41ae..0000000
--- a/tools/trac-wiki-to-markdown.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-# Untested code snippet from https://gist.github.com/somebox/619537
-
-class String
- def trac_to_markdown!
- gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`')
- gsub!(/\{\{\{(.+?)\}\}\}/m){|m| m.each_line.map{|x| "\t#{x}".gsub(/[\{\}]{3}/,'')}.join}
- gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '### \1')
- gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '## \1')
- gsub!(/\=\=\s(.+?)\s\=\=/, '# \1')
- gsub!(/\=\s(.+?)\s\=[\s\n]*/, '')
- gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, '[\2](\1)')
- gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
- gsub!(/'''(.+)'''/, '*\1*')
- gsub!(/''(.+)''/, '_\1_')
- gsub!(/^\s\*/, '*')
- gsub!(/^\s\d\./, '1.')
-
- gsub!(/\{\{\{([^\n]+?)\}\}\}/, '`\1`')
- gsub!(/'''(.+?)'''/, '**\1**')
- gsub!(/''(.+?)''/, '*\1*')
- gsub!(/((^\|\|[^\n\r]+\|\|[ \t]*\r?(\n|$))+)/m) do |m|
- m = m.each_line.map do |x|
- x.gsub(/\t/, ' ')
- .gsub(/(\|\|){2,}/){|k| k.gsub(/\|\|/, '|| ')}
- .gsub(/ {3,}/, ' ')
- end.join
- lines = m.each_line.to_a
- line1 = lines.shift
- line2 = line1.dup.gsub(/[^\n\r\|]/, '-')
- lines.unshift(line1, line2)
- c = lines.join
- c = c.each_line.map do |x|
- x.gsub(/\=\s?(.+?)\s?=/, ' \1 ')
- .gsub(/\|\|/, '|')
- end.join
- end
- gsub!(/^\{\{\{(.+?)^\}\}\}/m, '```\1```')
- gsub!(/\=\=\=\=\s(.+?)\s\=\=\=\=/, '### \1')
- gsub!(/\=\=\=\s(.+?)\s\=\=\=/, '## \1')
- gsub!(/\=\=\s(.+?)\s\=\=/, '# \1')
- gsub!(/\=\s(.+?)\s\=[\s\n]*/, '')
- gsub!(/\[(http[^\s\[\]]+)\s([^\[\]]+)\]/, '[\2](\1)')
- gsub!(/\!(([A-Z][a-z0-9]+){2,})/, '\1')
- gsub!(/^\s\*/, '*')
- gsub!(/^\s\d\./, '1.')
- end
-end
-
-some_trac = 'my document'
-
-puts some_trac.trac_to_markdown!