gomarkdown / markdown

markdown parser and HTML renderer for Go
Other
1.41k stars 173 forks source link

Indented HTML image is displayed as code block #237

Closed DenisDuev closed 2 weeks ago

DenisDuev commented 2 years ago

https://babelmark.github.io/?text=++%3Cdiv+style%3D%22text-align%3Acenter%22%3E%0A++++%3Cimg+src%3D%22https%3A%2F%2Fhatrabbits.com%2Fwp-content%2Fuploads%2F2017%2F01%2Frandom-word-1.jpg%22%3E%0A++%3C%2Fdiv%3E

For example if you have in Markdown:

  <div style="text-align:center">
    <img src="https://hatrabbits.com/wp-content/uploads/2017/01/random-word-1.jpg">
  </div>

It is parsed as:

<p>
</p>
<div style="text-align:center">
  <pre>
    <code>
      "<img src="https://hatrabbits.com/wp-content/uploads/2017/01/random-word-1.jpg">"
    </code></pre>
  <p>
  </p>
</div>

Desired behaviour:

image

<div style="text-align:center">
  <img src="https://hatrabbits.com/wp-content/uploads/2017/01/random-word-1.jpg" />
</div>
chrishrb commented 2 weeks ago

i have the same issue.. did you solve it?

kjk commented 2 weeks ago

If you DON'T use parser.NoEmptyLineBeforeBlock you should get the desired result.

See https://arslexis.io/goplayground/#pX39LsvNAhh