md module
[pinopress.git] / modules / md
diff --git a/modules/md b/modules/md
new file mode 100755 (executable)
index 0000000..b2bc038
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sed -Ef
+
+## markdown to html module for pinopress
+## based off https://github.com/stamby/md-to-html
+# input $1 - filepath to html file
+
+# special html characters
+s/\&/\&amp\;/g
+s/</\&lt\;/g
+s/>/\&gt\;/g
+
+# inline styles
+s/(^|[^\\\*])\*{3}([^\*]+)\*{3}([^\*]|$)/\1<strong><em>\2<\/em><\/strong>\3/g
+s/(^|[^\\_])_{3}([^_]+)_{3}([^_]|$)/\1<strong><em>\2<\/em><\/strong>\3/g
+s/(^|[^\\\*])\*{2}([^\*]+)\*{2}([^\*]|$)/\1<strong>\2<\/strong>\3/g
+s/(^|[^\\_])_{2}([^\_]+)_{2}([^_]|$)/\1<strong>\2<\/strong>\3/g
+s/(^|[^\\\*])\*([^\*]+)\*([^\*]|$)/\1<em>\2<\/em>\3/g
+s/(^|[^\\_])_([^_]+)_([^_]|$)/\1<em>\2<\/em>\3/g
+s/(^|[^\\`])`([^`]+)`([^`]|$)/\1<code>\2<\/code>\3/g
+
+# img
+s/!\[(.*)\]\((.*)\)/<img src="\2" alt="\1"\/>/g
+
+# links
+s/\[(.*)\]\((.*)\)/<a href="\1">\2<\/a>/g
+s/\[(.*)\]/<a href="\1">\1<\/a>/g
+
+# headers
+s/^#{4} (.*)/<h4>\1<\/h4>/
+s/^#{3} (.*)/<h3>\1<\/h3>/
+s/^#{2} (.*)/<h2>\1<\/h2>/
+s/^#} (.*)/<h1>\1<\/h1>/
+
+# html style comments
+