3 ## markdown to html module for pinopress
4 ## based off https://github.com/stamby/md-to-html
9 ## matches block of -- at top of file
10 1,/^([^-]|-[^-]|^$)/ {
16 # special html characters
24 # check if hold space contains READING
25 # this is to see if this is the first ``` we read or no
27 # if it is the first one, add READING to hold space
34 # if its the second ```, we are done
38 # then write closing tag
42 # if we aren't reading ```, but hold space has READING in it
43 # that means we are currently processing a block, just ignore and
57 s/^\s*-{3,}\s*$/<hr\/>/
60 s/(^|[^\\\*])\*{3}([^\*]+)\*{3}([^\*]|$)/\1<strong><em>\2<\/em><\/strong>\3/g
61 s/(^|[^\\_])_{3}([^_]+)_{3}([^_]|$)/\1<strong><em>\2<\/em><\/strong>\3/g
62 s/(^|[^\\\*])\*{2}([^\*]+)\*{2}([^\*]|$)/\1<strong>\2<\/strong>\3/g
63 s/(^|[^\\_])_{2}([^\_]+)_{2}([^_]|$)/\1<strong>\2<\/strong>\3/g
64 s/(^|[^\\\*])\*([^\*]+)\*([^\*]|$)/\1<em>\2<\/em>\3/g
65 s/(^|[^\\_])_([^_]+)_([^_]|$)/\1<em>\2<\/em>\3/g
66 s/(^|[^\\`])`([^`]+)`([^`]|$)/\1<code>\2<\/code>\3/g
67 s/(^|[^\\~])~{2}([^~]+)~{2}([^~]|$)/\1<del>\2<\/del>\3/g
70 s/!\[(.*)\]\((.*)\)/<img src="\2" alt="\1"\/>/g
73 s/\[(.*)\]\((.*)\)/<a href="\1">\2<\/a>/g
74 s/\[(.*)\]/<a href="\1">\1<\/a>/g
77 s/^#{6} (.*)/<h6>\1<\/h6>/
78 s/^#{5} (.*)/<h5>\1<\/h5>/
79 s/^#{4} (.*)/<h4>\1<\/h4>/
80 s/^#{3} (.*)/<h3>\1<\/h3>/
81 s/^#{2} (.*)/<h2>\1<\/h2>/
82 s/^#} (.*)/<h1>\1<\/h1>/
86 # /./{H;$!d} ; x ; s/^/\n<p>/ ; s/$/\n<\/p>/