dart-lang / markdown

A Dart markdown library
https://pub.dev/packages/markdown
BSD 3-Clause "New" or "Revised" License
450 stars 201 forks source link

Italalic and bold interactions, convert to html the italic format is error #432

Closed chifandeyu closed 2 years ago

chifandeyu commented 2 years ago

String markdown = 'a_bc**d_e**'; final html = markdownToHtml(markdown); then html is '

ah_ehfa_uhdf

'

srawlins commented 2 years ago

Er, I think your example is not right. For example there are no hs in the input text.

And just to make sure that I can tell what the output is which you do not like, can you show the raw HTML, rather than HTML which my browser is interpreting.

What output do you expect to see?

chifandeyu commented 2 years ago

Er, I think your example is not right. For example there are no hs in the input text.

And just to make sure that I can tell what the output is which you do not like, can you show the raw HTML, rather than HTML which my browser is interpreting.

What output do you expect to see?

Thank you for your reply. I want to convert like that format text: image

srawlins commented 2 years ago

Please show the HTML tags that you expect. If I had to guess at what you pasted, it looks like you want the em and strong tags to cross over each other, which is not allowed in HTML.

The Dart markdown package adheres to the CommonMark standard, which would output <p>a_bc<strong>d_e</strong></p>. See https://babelmark.github.io/?text=a_bc**d_e**

chifandeyu commented 2 years ago

Please show the HTML tags that you expect. If I had to guess at what you pasted, it looks like you want the em and strong tags to cross over each other, which is not allowed in HTML.

The Dart markdown package adheres to the CommonMark standard, which would output <p>a_bc\<strong\>d_e\</strong\></p>. See https://babelmark.github.io/?text=a_bc**d_e**

<html>
<body>
<div>a<i>bc</i><i><b>d</b></i><b>e</b></div>
</body>
</html>

For the above markdown, it is converted by delta. Is the format wrong?

srawlins commented 2 years ago

OK cool, I see what you expect.

Yes the markdown package will not produce that output. I don't know if there is a way in pure markdown to get the output you desire, but you can use inline HTML tags perhaps: a<em>bc</em>**<em>d</em>e**.