You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
When CodeHilite is enabled, fenced_code includes the language class in list of general classes. #1032
$ python3 --versionPython 3.8.5
$ python3 -m pip show markdownpyName: MarkdownVersion: 3.3Summary: Python implementation of Markdown.Home-page: https://Python-Markdown.github.io/Author: Manfred Stienstra, Yuri takhteyev and Waylan limbergAuthor-email: waylan.limberg@icloud.comLicense: BSD LicenseLocation: /usr/local/lib/python3.8/dist-packagesRequires:Required-by: xxx
$ python3 -m pip show pygmentsName: PygmentsVersion: 2.7.1Summary: Pygments is a syntax highlighting package written in Python.Home-page: https://pygments.org/Author: Georg BrandlAuthor-email: georg@python.orgLicense: BSD LicenseLocation: /usr/local/lib/python3.8/site-packagesRequires:Required-by: xxx
According to this page https://pygments.org/docs/lexers/, there are so many possibilities that the language class mess up with other class with the same name.
When pygments is disabled, the class name has a language- prefix, which is acceptable.
It would be better if we always add language- prefix, or just remove it.
changed the title [-]Featuer request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/-][+]Feature request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/+]on Oct 8, 2020
The fenced_code extension does not alter the output provided by Pygments.
Usually I would say that that is what Pygments returns so that's what you get.
However, the c class is included based on the fact that you can define additional classes as documented here. However, the language class (the first one defined) should be handled separately from that and not be included in the general list of classes. In fact, I see the same behavior when codehilite is enabled but Pygments is not installed. The same input results in this output:
In this case, the error is more obvious as we have both class="c codehilite" on the pre tag and class="language-c" on the code tag. Of course, as Pygments doesn't include the language in its output, we don't see class="language-c" in Pygments' output. So, Pygments is not at fault here. We need to remove the language identifying class from the list of classes that we pass to Pygments. Actually, we probably need to remove the class from the list we pass to codehilite. So, yeah, this is a bug. Thank you for the report.
changed the title [-]Feature request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/-][+]When CodeHilite is enabled, fenced_code includes the language class in list of general classes.[/+]on Oct 8, 2020
We also have an inconsistency between codehilite and no-codehilite when Pygments is not available. In both cases the code should be wrapped in pre and code tags. However, in the codehilite case, the extra classes are assigned to the pre tag, while in the no-codehilite case, they are assigned to the code tag.
Activity
[-]Featuer request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/-][+]Feature request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/+]waylan commentedon Oct 8, 2020
As noted in the documentation
Usually I would say that that is what Pygments returns so that's what you get.
However, the
cclass is included based on the fact that you can define additional classes as documented here. However, the language class (the first one defined) should be handled separately from that and not be included in the general list of classes. In fact, I see the same behavior when codehilite is enabled but Pygments is not installed. The same input results in this output:In this case, the error is more obvious as we have both
class="c codehilite"on thepretag andclass="language-c"on thecodetag. Of course, as Pygments doesn't include the language in its output, we don't seeclass="language-c"in Pygments' output. So, Pygments is not at fault here. We need to remove the language identifying class from the list of classes that we pass to Pygments. Actually, we probably need to remove the class from the list we pass to codehilite. So, yeah, this is a bug. Thank you for the report.[-]Feature request: when CodeHilite pygments is enabled, always add lang_prefix or remove the language class[/-][+]When CodeHilite is enabled, fenced_code includes the language class in list of general classes.[/+]mitya57 commentedon Oct 8, 2020
FWIW, this behavior started happening with #816.
waylan commentedon Oct 8, 2020
We also have an inconsistency between codehilite and no-codehilite when Pygments is not available. In both cases the code should be wrapped in
preandcodetags. However, in the codehilite case, the extra classes are assigned to thepretag, while in the no-codehilite case, they are assigned to thecodetag.Ensure consistent handling of classes by fenced_code and codehilite
Ensure consistent handling of classes by fenced_code and codehilite
Ensure consistent handling of classes by fenced_code and codehilite
Ensure consistent handling of classes by fenced_code and codehilite (#…