Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

escaping problem #220

Closed
mojoLyon opened this issue Mar 13, 2018 · 4 comments
Closed

escaping problem #220

mojoLyon opened this issue Mar 13, 2018 · 4 comments

Comments

@mojoLyon
Copy link

mojoLyon commented Mar 13, 2018

Hello,
it seem there is a problem with the escaping of mark down syntax.

I actually have this :

<p><em>I have a twitter account , @_test where you can leave me a message</em></p>

And the rendered markdown is :

_I have a twitter account , @_test where you can leave me a message_

When convert to html the result is :

<p>_I have a twitter account , @<em>_test where you can leave me a message</em></p>
@domchristie
Copy link
Collaborator

Thanks for this. Escaping is hard! I will add this as a bug. Thanks again.

@mojoLyon
Copy link
Author

mojoLyon commented Mar 14, 2018

May be I don't see something, but I have a question :)

It seem the escape method is called only on Node.TEXT_NODE so shouldn't you escape special chars _,*,`,[,] in it?

With a sentence like <h1>Hello world!</h1><p><em>test <strong>sentense</strong> with <em>@_twitter</em> here</em></p> escape method will be called with the strings below no ?

  • Hello world!
  • test
  • sentense
  • @_twitter
  • here

@domchristie
Copy link
Collaborator

It seem the escape method is called only on Node.TEXT_NODE so shouldn't you escape special chars _,*,`,[,] in it?

Special characters are escaped in the escape method, but only whey they need to be. For example emphasis underscores (_) are escaped here: https://github.com/domchristie/turndown/blob/e370a75f4aee38dfbe926e529d0fb3acdd7e7cd8/src/turndown.js#L158-L161

One of the common issues raised was that the escape method could be too aggressive i.e. escaping characters that it didn't need to. More recent versions try to avoid escaping every character, for example:

https://github.com/domchristie/turndown/blob/e370a75f4aee38dfbe926e529d0fb3acdd7e7cd8/test/index.html#L752-L755

@domchristie
Copy link
Collaborator

Closed by #242 and released in v5.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants