I've achieved something similar by passing markdown into handlebars/ejs first before converting it to html