#!/bin/sed -Ef ## markdown to html module for pinopress ## based off https://github.com/stamby/md-to-html # input $1 - filepath to html file # remove document meta /^-- \w+: .+$/d # html style comments //d # special html characters s/\&/\&\;/g s/\<\;/g s/>/\>\;/g # horizontal rule s/^\s*-{3,}\s*$/
\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>/
# code block
# paragraphs
# /./{H;$!d} ; x ; s/^/\n
/ ; s/$/\n<\/p>/