syntax-tree/hast-util-raw

Exception on malformed HTML

pd4d10 opened this issue · 3 comments

Subject of the issue

It throws an error while processing text as follows:

<h4><code style="border-radi

us: 5px;"><br>

Your environment

  • OS: macOS 11.0
  • Packages: hast-util-raw v6.0.1
  • Env: node.js 12

Steps to reproduce

const md = `<h4><code style="border-radi

us: 5px;"><br>`;

const unified = require('unified');
const remarkParse = require('remark-parse');
const remarkRehype = require('remark-rehype');
const rehypeRaw = require('rehype-raw');
const rehypeStringify = require('rehype-stringify');

const html = unified()
  .use(remarkParse)
  .use(remarkRehype, { allowDangerousHtml: true })
  .use(rehypeRaw)
  .use(rehypeStringify)
  .processSync(md);

console.log(html);

That doesn’t really look like markdown 😅 What do you expect to happen?

Thanks, released a fix!

Thanks for the quick fix.

This bad case is reported by ByteMD's user. Practically we don't care what the parse result is... The point is it should not throw an error.