Javascript in md - trying not to beat a dead horse

I’ve searched high and low and many threads here are old, and many don’t seem to work with v0.61.0, and I’m sure I’m not unique in this. Please point me in the right direction. Thanks.

So, making a blog, and would like to put javascript within the blog post, specifically an ad which is served via js. When the site is published I’ll be allowing some others to publish, and these users may not be skilled enough to create extra code and files, like shortcodes, or such. I’d like to be able to copy/paste the ad code right into the markdown. Although putting this code as the {{ innner }} for a short code would be acceptable.

For example, Amazon provides a script with vars between the tags, and then followed by a script-tag with an src-attribute. I’ve tried, safeJS safeHTML – which just outputs the raw text rather than evaluating it. Tried back ticks. Tried plain js. Tried it all on one line, or just between the script-tags on one line, etc.

This isn’t a generic snippet of code that could live on the /posts/single.html template because this would be a product specific ad.



do you use anything like this in your config.yaml?

      unsafe: true

I’m using config.toml and had tried just (on a newline) unsafe: true and that basically just renders the code on the page.

If you use a TOML configuration file then you can’t straight copy/paste Grob’s YAML example.

Here’s a TOML example from the documentation to try:

      unsafe = true

That unsafe option should fix your situation and make it possible to execute JavaScript, HTML, and CSS inside a Markdown file.