/
b
}
# if its the second ```, we are done
# first clear hold
s/.*//
x
# then write closing tag
s/.*/<\\code>/
}
# if we aren't reading ```, but hold space has READING in it
# that means we are currently processing a block, just ignore and
# keep going
x
/^ *READING/ {
x
b
}
x
# html style comments
//d
# horizontal rule
s/^\s*-{3,}\s*$/
/
# inline styles
s/(^|[^\\\*])\*{3}([^\*]+)\*{3}([^\*]|$)/\1\2<\/em><\/strong>\3/g
s/(^|[^\\_])_{3}([^_]+)_{3}([^_]|$)/\1\2<\/em><\/strong>\3/g
s/(^|[^\\\*])\*{2}([^\*]+)\*{2}([^\*]|$)/\1\2<\/strong>\3/g
s/(^|[^\\_])_{2}([^\_]+)_{2}([^_]|$)/\1\2<\/strong>\3/g
s/(^|[^\\\*])\*([^\*]+)\*([^\*]|$)/\1\2<\/em>\3/g
s/(^|[^\\_])_([^_]+)_([^_]|$)/\1\2<\/em>\3/g
s/(^|[^\\`])`([^`]+)`([^`]|$)/\1\2<\/code>\3/g
s/(^|[^\\~])~{2}([^~]+)~{2}([^~]|$)/\1\2<\/del>\3/g
# images
s/!\[(.*)\]\((.*)\)//g
# links
s/\[(.*)\]\((.*)\)/\2<\/a>/g
s/\[(.*)\]/\1<\/a>/g
# headers
s/^#{6} (.*)/\1<\/h6>/
s/^#{5} (.*)/\1<\/h5>/
s/^#{4} (.*)/\1<\/h4>/
s/^#{3} (.*)/\1<\/h3>/
s/^#{2} (.*)/\1<\/h2>/
s/^#} (.*)/\1<\/h1>/
# paragraphs
# /./{H;$!d} ; x ; s/^/\n
/ ; s/$/\n<\/p>/