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

(html) Words directly following closing tag are highlighted as tag names #3044

Closed
SebastianSimon opened this issue Mar 10, 2021 · 1 comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language

Comments

@SebastianSimon
Copy link

Any possible tag name following a closing HTML tag (such as </i>) without whitespace in between is highlighted the same way as the tag name itself: with hljs-name.

This happens in a code block with class="language-html" and hljs.highlightAll(); in version 10.6.0.

Minimal test case:

<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/10.6.0/highlight.min.js"></script>

<pre><code class="language-html">&lt;!DOCTYPE html&gt;
&lt;html&gt;

&lt;head&gt;
  &lt;meta charset="UTF-8"/&gt;
  &lt;title&gt;Test&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
  &lt;i&gt;Content&lt;/i&gt; Text   &lt;!-- Text treated as normal text. (Correct) --&gt;
  &lt;i&gt;Content&lt;/i&gt;Text    &lt;!-- Text treated as tag name. (Incorrect) --&gt;
&lt;/body&gt;

&lt;/html&gt;</code></pre>

<pre><code class="language-html">&lt;i&gt;Content&lt;/i&gt; Text     &lt;!-- Text treated as normal text. (Correct) --&gt;
&lt;i&gt;Content&lt;/i&gt;Text      &lt;!-- Text treated as tag name. (Incorrect) --&gt;</code></pre>

<script>hljs.highlightAll();</script>

Code:

<i>Content</i> Text   <!-- Text treated as normal text. -->
<i>Content</i>Text    <!-- Text treated as tag name. -->

Screenshot:

Screenshot of the highlight.js highlighting

As I said, any possible tag name is highlighted like this: Text, Foo:Text, custom-element, but not 1number.

Expected behavior

GitHub’s highlighting does it correctly. Text should be highlighted as normal text, just like described in the HTML comments in the code.


I’ve encountered this on Stack Overflow.

@SebastianSimon SebastianSimon added bug help welcome Could use help from community language labels Mar 10, 2021
@joshgoebel
Copy link
Member

Confirm. Closing tag rule probably needs endsParent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue Should be easier for first time contributors help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants