HTML character entities throw "Expected valid tag name" error
See original GitHub issueDescription
When using HTML character entities like <
in a MDsveX page with SvelteKit, Vite throws an Expected valid tag name
error
(Note, before Vite 2.5.4 and SvelteKit 1.0.0-next.165 the error was a cryptic offset is longer than source length!
. Thanks to https://github.com/vitejs/vite/pull/4782 this is now fixed.)
Reproduction
https://github.com/vwkd/sveltekit-bugs/tree/mdsvex-character-references
- Run
npm run dev
- Observe error
Expected valid tag name
System Info
Binaries:
Node: 16.6.0 - ~/.nvm/versions/node/v16.6.0/bin/node
Yarn: 1.22.11 - ~/.nvm/versions/node/v16.6.0/bin/yarn
npm: 7.19.1 - ~/.nvm/versions/node/v16.6.0/bin/npm
npmPackages:
@sveltejs/adapter-static: ^1.0.0-next.11 => 1.0.0-next.18
@sveltejs/kit: next => 1.0.0-next.165
mdsvex: ^0.9.8 => 0.9.8
svelte: ^3.34.0 => 3.42.5
Additional context
Maybe related to https://github.com/sveltejs/svelte/issues/6440 ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:12 (4 by maintainers)
Top Results From Across the Web
"Expected valid tag name" when using special characters like
I am having an issue when using the < character inside a Markdown file. Even when replacing it with < . It seems...
Read more >Error Explanations for The W3C Markup Validation Service
An entity reference was found in the document, but there is no reference by that name defined. Often this is caused by misspelling...
Read more >13.2 Parsing HTML documents - HTML Standard - whatwg
This error occurs if the parser encounters the end of the input stream where a tag name is expected. In this case the...
Read more >What are invalid characters in XML - Stack Overflow
I tried looking for a list of characters that cannot be put in XML nodes without being in a CDATA. Can someone point...
Read more >SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
This string has to be valid JSON and will throw this error if incorrect syntax was encountered. Examples. JSON.parse() does not allow trailing...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
quickfix
much faster than fixing all the dependencies : ) how to apply with patch-package
digging deeper
node_modules/mdsvex/dist/main.cjs.js
output
where does this code come from? lets ask github - looks like parse-entities some traces later, this is called by
remark-parse.markdown
so the problem is …
simple but wrong: escaping
<
with&lt;
and>
with&gt;
would give false positives for examplewould become
so either set options via
.use(markdown, options)
or patch the markdown parser