If I want to write something like "low < high" in a <pre> or <pre><code> tag, the rendering shows only "low", plus some wrong new line afterwards:

# here we are in a pre/code tag

But it works within back-ticks and with 4 spaces indentation low < high # here are backticks

low < hight  # here is indented

However "high > low" renders without problems, although the bug above keeps adding spurious new lines.

# here we are in a pre/code tag
hight > low

high > low # here are backticks

hight > low  # here is indented

I'm using version 49.0.2623.108 Ubuntu 15.10 (64-bit)


Since everything in a pre is HTML, you have to properly escape the <, else it thinks it is the start of a HTML tag.

This gives the desired result:

# here we are in a pre/code tag
low &lt; high


# here we are in a pre/code tag
low < high

Related feature request to change this behavior (the propsal in the feature request goes against the HTML standards, where I have to agree with Shog9): Can we have the pre tag work as the code tag does for angle brackets?

| improve this answer | |
  • I see. I guess it makes sense. About the request in the link: I agree that no one should change HTML standards. However, would be possible to warn the user that there are un-matched tags or </> within <pre><code>? – Francesco Montesano Apr 22 '16 at 9:28

I tend to think that is and not a bug. How do you think the parser should distinguish between <pre>foo <code>, where you want the second < to be interpreted as start of an HTML tag, and <pre>low < high, where you want the second < to be escaped to &lt;?

When using HTML directly, you are in advanced territory; you are expected to do your escapes yourself as needed.

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .