Skip to content

Self-contained CSS (and JS) should use style (and script) tags rather than data URIs #3423

@alyssarosenzweig

Description

@alyssarosenzweig

At the moment, I have markdown files that need to be styled with foo.css. I run the command:

$ pandoc -f markdown -t html --css foo.css --standalone --self-contained bar.md > bar.html

This does work, but it embeds the CSS as a massive data URI included with a link tag, which prevents certain optimizations from occurring outside of pandoc. Instead, foo.css should be placed verbatim (or minified) into a <style> tag, avoiding the data URI entirely.

To work around this bug, I currently use:

$ echo "<style>" > /tmp/open && echo "</style>" > /tmp/close
$ pandoc -f markdown -t html -H /tmp/open -H foo.css -H /tmp/close --standalone --self-contained bar.md > bar.html

This works as expected, but it is decidedly messier than it needs to be.

For text formats (as opposed to self-contained images and the like), is there a good reason to use data URIs?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions