Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add commonmark-code-blocks filter for producing CommonMark-suggested HTML for fenced code blocks #224

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

dmbaturin
Copy link

Pandoc's implementation of CommonMark code block rendering differs from that suggested by the spec and used by most other Markdown convertors.

The suggested behavior is to output <code class="language-$lang">, while Pandoc omits the language- prefix, which may cause problems for syntax highlighters that rely on that spec-suggested behavior.

I made a simple filter to bring the code block rendering in line with the spec and other implementations.

It's used in one of my project's website build process for example, where pandoc is used as a Markdown to HTML convertor, but syntax highlighting is delegated to an external tool, and *[class^="language-"] CSS selector is used to find code elements with language specified.

@dmbaturin
Copy link
Author

Tests do pass in my environment (Fedora 35), so I'll need to find why the diff behavior is different in the CI container. I'll look into it today or tomorrow.

because DIFF is set to diff -u in the CI container image environment
@dmbaturin
Copy link
Author

Ok, found the issue. The cause was my use of DIFF ?= in the Makefile (which I copied from another Makefile in the same repo, which made me think it's a safe thing to do). In reality it wasn't because DIFF is set to diff -u globally in the container environment, so my options to ignore whitespace changes and trailing newlines were ignored.

I verified that the test passes in the docker test image.

@tarleb
Copy link
Member

tarleb commented Apr 19, 2022

Thank you for this useful filter. We are currently not merging any new filters into this repo, please see #207 for details.

@dmbaturin
Copy link
Author

@tarleb Maybe it's a good idea to add that information to the README and to CONTRIBUTING.md so that no one tries to open new pull requests.

There's no decision regarding the future structure yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants