"Expected valid tag name" when using special characters like <
See original GitHub issueHello @pngwn, thank you for this great project!
I am having an issue when using the <
character inside a Markdown file. Even when replacing it with <
. It seems the <
gets replaced by <
again resulting in the same error from the svelte compiler (“Expected valid tag name”). I even tried to escape the character with \
without success.
Is there any way to escape special characters so the svelte compiler does not throw an error?
My current “solution” is to wrap <
inside an inline code block but I do not want to show that part as code. This is the Markdown file I am talking about: https://github.com/nymea/nymea-plugins/blob/rework-readmes/awattar/README.md This is the version with the “fixed” inline code blocks. When removing those, the error gets thrown.
I am not sure if this is a bug or if I miss something here. Just found this code section in MDSveX:
// in code nodes replace the character witrh the html entities
// maybe I'll need more of these
const entites = [
[/</g, '<'],
[/>/g, '>'],
[/{/g, '{'],
[/}/g, '}'],
];
So I guess the <
character should only be replaced inside code blocks as mentioned in the comment, but using <
leads to the same error because somewhere during the preprocess it gets replaced with <
again.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:15 (9 by maintainers)
Top GitHub Comments
The commonmark specification has a list of rules for what constitutes legal tags. Anything that isn’t a valid tag is escaped. This example shows a < followed by a space is not considered a valid tag name. Eg,
< a>
encodes to< a>
. (As it does in this comment.)Commonmark has a test suite of JSON content. We should get that test suite passing in mdsevx.
Its awful but double escaping seems to work:
It doesn’t work in the playground though. For some reason
&
makes the playground hit another bug and error withDocument is not defined