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

Less-than sign (i.e., open angle bracket, '<') not escaped correctly #395

Open
telotortium opened this issue Jul 29, 2021 · 3 comments
Open

Comments

@telotortium
Copy link

I recently discovered https://github.com/notlmn/copy-as-markdown, which copies the selected HTML as Markdown. It fails to properly escape angle brackets. For example, in the current README.md for this repo, this text appears: <h1>1. Hello world</h1>. I would expect it to be converted to \<h1\>1. Hello world\</h1\> when I copy this plain text to Markdown. However, it instead appears without backslashes escaping the angle brackets.

In the code, I notice that in the escapes array, there is no entry at all for the open angle bracket <, and it appears that the close angle bracket '>' may only be escaped at the beginning of the string, although I haven't read the code enough to know for sure.

@pavelhoral
Copy link
Collaborator

Not sure I understand the issue. HTML blocks are not escaped. Also the <h1>1. Hello world</h1> in is not escaped in the source as well (mainly because it is part of code block there, but that makes your example kind of invalid).

@martincizek
Copy link
Collaborator

Please always provide a sample input and output that reproduces the issue.

If I understand it correctly, the issue is that e.g. turndownService.turndown('...&lt;h1&gt;...') becomes ...<h1>..., is that correct?

Btw. this issue will be addressed by the advanced escaping subsystem that is planned. It will be adopted from gfm-escape, which addresses also this. But I guess we should address it already in the current escape subsystem as well.

Please confirm the example above is the case.

@holm
Copy link

holm commented Jan 25, 2022

Just wanted to mention that we also ran into this issue now. We would expect turndownService.turndown('...&lt;h1&gt;...') to be come ...\<h1\>....

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

No branches or pull requests

4 participants