Search code examples
javascripthtmlmarkdownpandoc

pandoc: add html events such as onload when converting from markdown


When converting from Markdown to HTML, I'd love to add a custom onload event handler in the generated html page, like this:

<body onload="myOnLoad();">

It this possible with pandoc? How?


Solution

  • There are two possibilities:

    1. use a custom template, see the pandoc manual section on templates, or
    2. write a short JavaScript script which uses the addEventListener method instead, and add the script to the document, e.g. via -H.