Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why isn't my CSS formatting showing up in Pandoc HTML documents?

I'm writing notes in Markdown which I want to convert to HTML using Pandoc, so that they're prettier when I look back over them. I am aware that CSS styling can be applied to documents converted with Pandoc by using the -c option, like so:

pandoc "ExamPrep.md" -c style.css -o "ExamPrep.html"

But this just doesn't seem to be working for me. For example, style.css includes the styling in this SO answer to add borders to tables, but my tables in the outputted HTML have no borders.

like image 685
murchu27 Avatar asked Nov 14 '25 17:11

murchu27


1 Answers

As noted by this comment on a gist with CSS for lovely Pandoc HTML styling, the --standalone flag has to be included for CSS styling to work, i.e.,

pandoc --standalone "ExamPrep.md" -c style.css -o "ExamPrep.html"

The Pandoc documentation for --standalone says that it:

Produce[s] output with an appropriate header and footer (e.g. a standalone HTML, LaTeX, TEI, or RTF file, not a fragment).

Without it, the resulting HTML has no header, and hence, no way of referencing the CSS file.

like image 177
murchu27 Avatar answered Nov 17 '25 10:11

murchu27