Created
May 12, 2012 20:42
-
-
Save maxpeterson/2668875 to your computer and use it in GitHub Desktop.
Convert Trac Wiki to Markdown
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
| # Convert Trac wiki to Markdown | |
| # Based in https://gist.github.com/619537/94091aa59bdf6d6e5ad2fbb063465b2d160156ad | |
| # | |
| # | |
| ################################################################################ | |
| # Single line code snippets | |
| # {{{XXX}}} | |
| # ==> | |
| # `XXX` | |
| # sed -i '' -Ee 's/{{{(.*)}}}/`\2`/' $@ | |
| # | |
| ################################################################################ | |
| # Multi line code snippets | |
| # {{{ | |
| # XXX | |
| # YYY | |
| # }}} | |
| # ==> | |
| # XXX | |
| # YYY | |
| #sed -i '' -Ee '/{{{/,/}}}/s/^/ /;/^ ({{{|}}})$/D;s/({{{|}}})//' $@ | |
| # | |
| ################################################################################ | |
| # Headings | |
| # ==== XXX ==== | |
| # ==> | |
| # #### XXX | |
| #sed -i '' -Ee 's/^======*([^=]*)======*/##### \1/' \ | |
| # -Ee 's/^====([^=][^=]*)====/#### \1/' \ | |
| # -Ee 's/^===([^=][^=]*)===/### \1/' \ | |
| # -Ee 's/^==([^=][^=]*)==/## \1/' \ | |
| # -Ee 's/^=([^=][^=]*)=/# \1/' $@ | |
| # | |
| ################################################################################ | |
| # Links | |
| # [http::/xyz.com XYZ] | |
| # ==> | |
| # (XYZ)[http::/xyz.com] | |
| #sed -i '' -Ee 's/\[(http[^ ]*) ([^]]*)\]/[\2](\1)/g' \ | |
| # -Ee 's/\[wiki:([^] ]*)\]/[\1](\1)/' \ | |
| # -Ee 's/\[wiki:([^] ]*) ([^]]*)\]/[\2](\1)/' $@ | |
| # | |
| ################################################################################ | |
| # Bold | |
| #sed -i '' -Ee "s/'''(.*)'''/*\1*/" $@ | |
| # | |
| ################################################################################ | |
| # Underline | |
| #sed -i '' -Ee "s/''([^']*)''/_\1_/" $@ | |
| # | |
| ################################################################################ | |
| # Unordered items | |
| #sed -i '' -Ee 's/^ \*/*/' $@ | |
| # | |
| ################################################################################ | |
| # Ordered items | |
| #sed -i '' -Ee 's/^ [0-9]\./1./' $@ | |
| # | |
| ################################################################################ | |
| sed -i '.md' -Ee 's/{{{(.*)}}}/`\1`/g' \ | |
| -Ee '/{{{/,/}}}/s/^/ /;/^ ({{{|}}})$/D;s/({{{|}}})//' \ | |
| -Ee 's/^======*([^=]*)======*$/##### \1/' \ | |
| -Ee 's/^====([^=][^=]*)====$/#### \1/' \ | |
| -Ee 's/^===([^=][^=]*)===$/### \1/' \ | |
| -Ee 's/^==([^=][^=]*)==$/## \1/' \ | |
| -Ee 's/^=([^=][^=]*)=$/# \1/' \ | |
| -Ee 's/\[(http[^ ]*) ([^]]*)\]/[\2](\1)/g' \ | |
| -Ee 's/\[wiki:([^] ]*)\]/[\1](\1)/' \ | |
| -Ee 's/\[wiki:([^] ]*) ([^]]*)\]/[\2](\1)/' \ | |
| -Ee "s/'''(.*)'''/*\1*/g" \ | |
| -Ee "s/''([^']*)''/_\1_/g" \ | |
| -Ee 's/^ \*/*/' \ | |
| -Ee 's/^ [0-9]\./1./' $@ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment