JavaScript highlighting breaks on left angle bracket (less-than, <)
See original GitHub issueThis may be reproduced with the jQuery code ( http://code.jquery.com/jquery-1.10.1.js )
The less-than <
operator, bit-shift operator <<
and some occurrences of <
in comments produce a tag
highlighting.
Examples from the jQuery code where tag
is produced:
// BMP codepoint
high < 0 ?
// Support: Android<4.0
// Detect silently failing push.apply
// Support: Chrome<<14
// Always assume duplicates if they aren't passed to the comparison function
// General-purpose constants
strundefined = typeof undefined,
MAX_NEGATIVE = 1 << 31,
It looks like a major bug to me.
Also looks like the following lines of the language definition somehow connected to the issue, but I don’t exactly sure how to fix it (and if they are the only cause):
{ // E4X
begin: '<', end: '>;',
subLanguage: 'xml'
}
Issue Analytics
- State:
- Created 10 years ago
- Comments:12 (7 by maintainers)
Top Results From Across the Web
How to disable angle bracket highlighting in Visual Studio ...
Show activity on this post. You can use the following: // Highlight matching brackets when one of them is selected. "editor. matchBrackets": ...
Read more >Markdown: Syntax
Left angle brackets are used to start tags; ampersands are used to denote HTML entities. If you want to use them as literal...
Read more >Grouping operator ( ) - JavaScript - MDN Web Docs
The grouping operator consists of a pair of parentheses around an expression that groups the contents. The operator overrides the normal ...
Read more >HTML Entities - W3Schools
If you use the less than (<) or greater than (>) signs in your text, the browser might ... A commonly used entity...
Read more >Query Parser Syntax - Apache Lucene
Terms. A query is broken up into terms and operators. There are two types of terms: Single Terms and Phrases. A Single Term...
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 FreeTop 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
Top GitHub Comments
@unilobo the behavior you’re seeing is not caused by this bug which deals with a raw staring to highlight. Yours is just plain lack of escaping in HTML: you need to escape
<
in HTML if you want it literally.<code>
has no special escaping rules and<h2>
inside<code>
is just a tag, same as everywhere else. This has nothing to do with highlight.js, really 😃Hey, just using version 8/9 and this seems to suffer the same problem?
Namely, html does not display correctly unless replacing left angle bracket with <<;.
I wish you would mention this in docs/readme. d:)
Is this expected behavior or a bug?
Example here;
http://codepen.io/2dareis2do/pen/ygdWXV