`<` sign rendered as beginning of new HTML element
See original GitHub issueI’ve been looking online and checked the documentation, but I found nothing on this issue.
It might be no issue though. I’m placing the C++ code inside the
<pre>
<code>
#include <stdio.h>
</code>
</pre>
And in the HTML it’s rendered as
#include
and when inspect the code it looks like the new HTML element is created
<span class="hljs-meta">
#
<span class="hljs-meta-keyword">include</span>
</span>
<stdio.h></stdio.h>
Am I doing something wrong? Any help would be appreciated. Thanks
Browser: Chrome Version 47.0.2526.73 (64-bit)
Issue Analytics
- State:
- Created 8 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
<pre>: The Preformatted Text element - HTML - MDN Web Docs
The <pre> HTML element represents preformatted text which is to be presented exactly as written in the HTML file. The text is typically ......
Read more >React Render HTML - W3Schools
The purpose of the function is to display the specified HTML code inside the specified HTML element. But render where? There is another...
Read more >WebD2: Common HTML Tags - University of Washington
An opening tag begins a section of page content, and a closing tag ends it. For example, to markup a section of text...
Read more >Structural markup and right-to-left text in HTML - W3C
Use the dir attribute on a block element only when you need to change the base direction of content in that block. Having...
Read more >Render HTML element in browser - javascript - Stack Overflow
using jQuery is a bit much here, but usually simple for a start. //learn ...
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
<pre>
in HTML doesn’t mean that text inside it will be auto escaped. This is in fact a common misconception. If highlight.js were to suddenly interpret tags inside<pre>
literally, it would be a) quite surprising to people who do know how it works and b) would prevent people from having custom markup inside it. For example, right now you can do something like:That wouldn’t be possible if we would autoescape it.
Also, you’re supposed to pre-escape any text you want to put inside HTML anyway for security purposes. It would be really cumbersome to force people who do it do something like
if (it's a "pre" tag && highlight.js is active) { unescape text back }
.Clearly I understand how to escape chars to html entities, but from my perspective if highlight.js forces to use
<pre>
tags in browser, it need to support out of the box this feature.