pablo-abc / svelte-markdown

Markdown parser to svelte components
MIT License
360 stars 50 forks source link

`isInline` option causes issues when parsing HTML #96

Open brunobely opened 3 months ago

brunobely commented 3 months ago

Having the isInline option in this case seems to duplicate the HTML tags. When I pass it the following as source:

<p>Enter your details below to get your <span class="text-primary">personalized</span> challenge!</p>

I get the following HTML out:

<p>
  <!-- HTML_TAG_END -->
  Enter your details below to get your
  <!-- HTML_TAG_START -->
  <span class="text-primary">
    <!-- HTML_TAG_END -->
    personalized
    <!-- HTML_TAG_START -->
  </span>
  <!-- HTML_TAG_END -->
  challenge!
  <!-- HTML_TAG_START -->
</p>
<p>
  Enter your details below to get your <span class="text-primary"></span>personalized challenge!<p>
</p>

If I omit the outerp, input (for this test case, the output is incorrect even with isInline={false}--it outputs the contents of the span twice, once in the span tag and once outside, see below):

Enter your details below to get your <span class="text-primary">personalized</span> challenge!

I get:

isInline={true}:

Enter your details below to get your <span class="text-primary"></span>personalized challenge!

isInline={false}:

Enter your details below to get your
<span class="text-primary">
  <!-- HTML_TAG_END -->
  personalized
  <!-- HTML_TAG_START -->
</span>personalized challenge!</h2>

Can't create a Svelte REPL to reproduce because of the following issue when trying to import svelte-markdown:

"Slugger" is not exported by "https://unpkg.com/marked@14.0.0/lib/marked.esm.js", imported by "https://unpkg.com/svelte-markdown@0.4.1/src/markdown-parser.js".