Including a javascript file with pandoc when going from markdown to html
Asked Answered
T

2

9

I am using pandoc to convert a markdown file to standalone html file. I have css file that I include with the -c command-line option. I would like to do the same thing with a javascript file, but I have not found an option to include script files similar to the -c option.

Is there such an option? If not, what is the most efficient way to do the inclusion?

Transportation answered 21/2, 2017 at 10:19 Comment(0)
B
15

Use the header-includes variable in the YAML metadata header (and run pandoc -s):

---
header-includes: <script src="foo"></script>
---

my markdown document
Brianna answered 21/2, 2017 at 15:33 Comment(4)
the link points to the manual, not directly to the variable. Maybe they released the anchors in the help.Mccutcheon
@Mccutcheon thanks, I updated the link to the section where it's been moved to...Brianna
how did you know that there is an anchor? My answer below also has a link, but the https://pandoc.org/MANUAL.html#General-writer-options url does not work properly because the anchor is not really correct.Mccutcheon
developer.mozilla.org/en-US/docs/Tools/Page_Inspector/How_to/… :-)Brianna
M
7

More convenient could be to use the flag

`-H FILE, --include-in-header=FILE|URL`

as described here in the pandoc call. It implies --standalone.

Mccutcheon answered 23/6, 2020 at 6:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.