Skip to content

Leveraging parse5

Compare
Choose a tag to compare
@motss motss released this 28 Apr 08:40
· 265 commits to main since this release

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>