Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Markdown rendering strips tags from HTML code blocks #64

Closed
codingkoi opened this issue Feb 23, 2023 · 3 comments
Closed

Markdown rendering strips tags from HTML code blocks #64

codingkoi opened this issue Feb 23, 2023 · 3 comments

Comments

@codingkoi
Copy link

codingkoi commented Feb 23, 2023

I've run into a problem using refractor 4.8.0 where when a Markdown code block is specified to be html, any tags inside that block get stripped out completely.

A minimal example that reproduces the issue is this snippet of Markdown:

```html
<h1>Some HTML</h1>
```

I set up a Replit example that shows the result of rendering this looks like:

<span class="token code"><span class="token punctuation">```</span><span class="token code-language">html</span>
<span class="token code-block language-html">Some HTML</span>
<span class="token punctuation">```</span></span>

As you can see, the H1 tags are completely gone.

It also only does this if you put the html language on the code block. Without it, the tags aren't stripped out.

Am I using the library wrong? It seems that if I replace the < and > with &lt; and &gt;, that fixes the issue, but if I do that on a full Markdown file, any inlined HTML tags will not be highlighted. It also doesn't seem like that sort of escaping is needed for other file types (e.g. JavaScript).

It looks like this is being caused because of textContent in markdown.js, but I don't know that changing that is the right solution here (or I'd open a PR 😀).

Let me know if you need any more information, or if I can help. Thanks!

@wooorm
Copy link
Owner

wooorm commented Feb 26, 2023

You found a bug! Weird!

@wooorm wooorm closed this as completed in 9186068 Feb 28, 2023
@codingkoi
Copy link
Author

Awesome! Thanks for the quick turnaround. I'll give it a try and let you know if I have any further issues.

@wooorm
Copy link
Owner

wooorm commented Feb 28, 2023

:)

Released in 4.8.1!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants