sveltedoc-parser
sveltedoc-parser copied to clipboard
The parseFileStructureFromContent works wrong sometimes
The following input of markup returns the wrong output for script blocks
<script>
const example = `
<script>
</script>
`;
</script>
I was browsing the Svelte issues and actually, this is not a bug: https://github.com/sveltejs/svelte/issues/5810
If a developer wants to put </script> in a string literal or comment, it has to be escaped.
The following code should be correct for svelte, but this parser failed there:
<Panel title="Basic tabs" shadow={true}>
<Tabs bind:items={items}/>
<br><br>
<strong>Active tab:</strong> {activeTab1[0].title}
<br>
<br>
<Code>
{@html highlight(
'<script> \n' +
' const items = [ \n' +
' { title: "Tab 1", active: true }, \n' +
' { title: "Tab 2", active: false }, \n' +
' { title: "Tab 3", active: false }, \n' +
' { title: "Tab 4", active: false }, \n' +
' ]; \n' +
'</script> \n\n' +
'<Tabs bind:items={items} />')}
</Code>
</Panel>
The test was added in test\unit\helpers\helpers.spec.js