Leveraging parse5
lit-ntml
now parses content (or HTML string) as HTML fragment string.
Unless parseHtml
flag is set to true, the final content is parsed as HTML string instead.
/* To parse as HTML string */
import { ntml } from 'lit-ntml';
const html = ntml({ parseHtml: true });
await html`<div>
<h1>Hello, World!</h1>
</div>`;
// <!doctype html><html>...<body>...<div><h1>Hello, World!</h1></div>...</body>...</html>
/* Everything is parsed as HTML fragment string by default */
import { ntml } from 'lit-ntml';
const html = ntml(); // or ntml({ parseHtml: false });
await html`<div>
<h1>Hello, World!</h1>
</div>`;
// <div><h1>Hello, World!</h1></div>