Skip to content

Instantly share code, notes, and snippets.

@madeindjs
Last active May 15, 2017 09:13
Show Gist options
  • Save madeindjs/0ca618a63f03ea8c6ce4c3db181fec78 to your computer and use it in GitHub Desktop.
Save madeindjs/0ca618a63f03ea8c6ce4c3db181fec78 to your computer and use it in GitHub Desktop.
A simple markdown converted to Wiki formating using SED
#!/bin/bash
cat "$1" |
# code block tags
sed -E 's/(~~~|```)([a-z]+)/<pre><code class="\2">/g' |
sed -E 's|(~~~\|```)|</pre></code>|g' |
# inline code tag
sed -E 's/`(.*)`/@\1@/g' |
# italic tag
sed -E 's/\*/_/g' |
# bold tag
sed -E 's/__/\*/g' |
# replace title tag
sed -E 's/#+ (.*)/\+\*\1\*\+/g' |
# list
sed -E 's/_ /\* /g'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment