showdownjs / showdown

A bidirectional Markdown to HTML to Markdown converter written in Javascript
http://www.showdownjs.com/
MIT License
14.23k stars 1.56k forks source link

Characters " " inside Code Block instead of space #669

Open yoric-m opened 5 years ago

yoric-m commented 5 years ago

I'm a new Showdown user, experimenting the CLI tool to convert my markdown pages into static html files for my blog. I'm very happy with it so far. However, I just stumbled upon a Gotcha while copy/pasting my directory structure inside a block of code (using the triple backticks).

Does someone knows why the rendering with Showdown is like this:

tree
├── folder1
│   └── a.txt
└── folder2
    └── b.txt

While it is like this in other markdown to html converter (and also here on Github):

tree
├── folder1
│   └── a.txt
└── folder2
    └── b.txt

It looks like Showdown is putting &amp;nbsp; inside the <pre><code> tag instead of &nbsp; to render the space character.

I'm really not sure if I'm misusing it or if it's a bug. Does anyone one has an idea about it?

tivie commented 5 years ago

Bug confirmed.

The input text has non-breaking spaces inside the code block which get converted to the correspondent html entity &nbsp;. However, then the code block is encoded again, changing & to &amp; resulting in that weird behavior.

djlxiaoshi commented 3 years ago

i met the same problem

gengue commented 3 years ago

Same here, I got this: ¨NBSP;

Stonks3141 commented 2 years ago

Same here, => { becomes =&gt; { in <pre><code> and <code> blocks. Inspecting reveals =&amp;gt {.

tivie commented 2 years ago

we are working on a fix for this (and other related issues).

tivie commented 2 years ago

should be fixed. Will be merged in develop soon.