The server parser is a wrapper of htmlparser2parseDOM but with the root parent node excluded. The next section shows the available options you can use with the server parse.
The client parser mimics the server parser by using the DOM API to parse the HTML string.
Options
Browser
trustedTypePolicy
When running in a browser, you can pass a Trusted Types policy so the parser calls trustedTypePolicy.createHTML before assigning content to innerHTML:
Because the server parser is a wrapper of htmlparser2, which implements domhandler, you can alter how the server parser parses your code with the options:
export interface ParserOptions { /** * Indicates whether special tags (`<script>`, `<style>`, and `<title>`) should get special treatment * and if "empty" tags (eg. `<br>`) can have children. If `false`, the content of special tags * will be text only. For feeds and other XML content (documents that don't consist of HTML), * set this to `true`. * * @default false */ xmlMode?: boolean; /** * Decode entities within the document. * * @default true */ decodeEntities?: boolean; /** * If set to true, all tags will be lowercased. * * @default !xmlMode */ lowerCaseTags?:
If you're parsing SVG, you can set lowerCaseTags to true without having to enable xmlMode. This will return all tag names in camelCase and not the HTML standard of lowercase.
[!NOTE]
If you're parsing code client-side (in-browser), you cannot control the parsing options. Client-side parsing automatically handles returning some HTML tags in camelCase, such as specific SVG elements, but returns all other tags lowercased according to the HTML standard.
Migration
v8
Changed build output to target ES6 instead of ES5.