unclean work with class names (adding unneeded spaces during DOM manipulations)
See original GitHub issueInformation:
- Prism version: latest (from the master branch)
- Plugins: none
- Environment: Browser
Description
The way how PrismJS works with class attributes for languages (See: https://github.com/PrismJS/prism/blob/master/components/prism-core.js#L260) is unclean since it introduces unnecessary leading white space, e.g. if the original HTML was:
<pre class="highlight">
<code class="language-css">
some code
</code>
</pre>
After PrismJS.highlightAll() it would become (there are two spaces in front of language-XXX
instead of one:
<pre class="highlight language-css">
<code class=" language-css">
some code
</code>
</pre>
It is a minor, mostly cosmetic issue, but it would be nice if PrismJS did the right thing and introduced the leading white space only if there is something in the class line already (and definitely use one space in that case 😃 )
Issue Analytics
- State:
- Created 3 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
How to add/remove a class in JavaScript? - Stack Overflow
Here is solution for addClass, removeClass, hasClass in pure javascript solution. ... classList which has remove(name) , add(name) , toggle(name) ...
Read more >Why React classnames Is A Lifesaver And How You Could ...
In this tutorial, I cover why you should use classnames and how to use it ... just for the sake of changing up...
Read more >How whitespace is handled by HTML, CSS, and in the DOM
Whitespace is any string of text composed only of spaces, tabs or line breaks (to be precise, CRLF sequences, carriage returns or line...
Read more >Fighting the Space Between Inline Block Elements | CSS-Tricks
A series of inline-block elements with "normal" HTML formatting result in spaces between them when set on the same line.
Read more >Google JavaScript Style Guide
Default import names are derived from the imported file name and follow the rules in 6.2 Rules by identifier type. import MyClass from...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
So it actually does cause problems. I’ll make a fix shortly.
@RunDevelopment
Oh, thank you very much for your quick reply. In fact, I was already writing, but I made a mistake in a parameter, so it did not take effect. See your code, I corrected the first parameter of the function, and it was able to run. On this basis, I tried to add the class on the
<pre>
(if it exists), and done.👏👏👏 😀