sveltedoc-parser icon indicating copy to clipboard operation
sveltedoc-parser copied to clipboard

The parseFileStructureFromContent works wrong sometimes

Open alexprey opened this issue 4 years ago • 3 comments

The following input of markup returns the wrong output for script blocks

<script>
const example = `
    <script>
    </script>
`;
</script>

alexprey avatar Feb 02 '21 17:02 alexprey

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.

soft-decay avatar Feb 10 '21 15:02 soft-decay

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>

alexprey avatar Feb 12 '21 16:02 alexprey

The test was added in test\unit\helpers\helpers.spec.js

alexprey avatar Feb 12 '21 16:02 alexprey