`language-js` also results in class `javascript` being applied
See original GitHub issueRepurposing this issue for the larger question/problem that it has brought up as mentioned in the comments below at:
https://github.com/highlightjs/highlight.js/issues/3023#issuecomment-787105999
Summary:
language-js
will also apply thejavascript
classlanguage-javascript
will NOT apply thejavascript
class- some themes require un-prefixed class names to work properly (ie they apply per language themes)
Describe the issue When I add the “language-php” class to the code element, the coloring is okay, but it adds an extra php tag. If I don’t give a class, it adds the php class and there is no problem.
Which language seems to have the issue? Only php, i haven’t seen such problem in other languages
Are you using highlight
or highlightAuto
?
highlightAll
Sample Code to Reproduce
You can take a look at the php block. Other languages seem to be fine.
Expected behavior When we add the “language-php” class to the code element, it should not add the extra php tag.
Issue Analytics
- State:
- Created 3 years ago
- Comments:15 (15 by maintainers)
@Hirse CCing you since you’ve done some theme work.
Part of the problem is I’m not sure there is any spec here at all.
hljs-[name]
would be the safest choice from a “do not conflict with other class names” perspective. But then we have a problem if a new language would ever overlap with a highlighting class… so now you’re back tohljs-language-[name]
… a bit of a mouthful, but precise enough.One can also easily do this with a one-line plugin… should we perhaps just let those who wish to have such things do it themselves?
Example:
https://github.com/highlightjs/highlight.js/blob/main/docs/plugin-recipes.rst#data-language
CC @allejo
So I’m kind of leaning towards:
hljs-language-[grammar name]
precise and hopefully future proof.Don’t feel I have a strong preference. Either would be a breaking change so this needs to be decided before v11.