{"name":"dom-serializer","version":"3.1.0","keywords":["html","xml","render"],"author":{"name":"Felix Boehm","email":"me@feedic.com"},"license":"MIT","_id":"dom-serializer@3.1.0","maintainers":[{"name":"fb55","email":"me@feedic.com"}],"homepage":"https://github.com/cheeriojs/dom-serializer#readme","bugs":{"url":"https://github.com/cheeriojs/dom-serializer/issues"},"dist":{"shasum":"9b014ce896afd00c51e4cae04daf39994c7c9754","tarball":"http://registry-npm.ywwl.com/dom-serializer/download/dom-serializer-3.1.0.tgz","fileCount":13,"integrity":"sha512-CKlTGQ6lF20Q2aDsHA2AjYM+x9zkFx7Sai95m2RPOCiSR21C2LRdBNQmDMbViWHHzK0xWjuo0SC9brGlIC+l6w==","signatures":[{"sig":"MEYCIQC+U7WRsyYQ+yuAwODuWY8GtvhYL46qntVZLVd2Gf75vwIhALkYNbhRna8DCNosdHZFjm9Y9r8aBG1OfbicyvCYzCF8","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/dom-serializer@3.1.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":38063,"size":10627,"noattachment":false,"key":"/dom-serializer/-/dom-serializer-3.1.0.tgz"},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.19.0"},"exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"}},"funding":{"url":"https://github.com/cheeriojs/dom-serializer?sponsor=1","type":"github"},"gitHead":"c0b5020684e112355d4795f0c5b83b9774d5c8d1","scripts":{"lint":"npm run lint:es && npm run lint:ts && npm run lint:biome","test":"npm run test:vi && npm run lint","build":"tsc","format":"npm run format:es && npm run format:biome","lint:es":"eslint .","lint:ts":"tsc --noEmit -p tsconfig.eslint.json","prepare":"npm run build","test:vi":"vitest run","format:es":"npm run lint:es -- --fix","lint:biome":"biome check .","format:biome":"biome check --write ."},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:fc60f0e3-5ad6-401b-8d88-2eb66674df3a"}},"repository":{"url":"git://github.com/cheeriojs/dom-serializer.git","type":"git"},"_npmVersion":"11.11.0","description":"render domhandler DOM nodes to a string","directories":{},"sideEffects":false,"_nodeVersion":"24.14.1","dependencies":{"entities":"^8.0.0","domhandler":"^6.0.0","domelementtype":"^3.0.0"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^10.3.0","vitest":"^4.1.5","cheerio":"^1.2.0","typescript":"^6.0.2","@types/node":"^25.6.0","@biomejs/biome":"^2.4.14","@eslint/compat":"^2.0.5","typescript-eslint":"^8.59.1","eslint-config-biome":"^2.1.3","@feedic/eslint-config":"^0.4.1"},"_npmOperationalInternal":{"tmp":"tmp/dom-serializer_3.1.0_1777721042164_0.25761896178371857","host":"s3://npm-registry-packages-npm-production"},"readme":"# dom-serializer [![Node.js CI](https://github.com/cheeriojs/dom-serializer/actions/workflows/nodejs-test.yml/badge.svg)](https://github.com/cheeriojs/dom-serializer/actions/workflows/nodejs-test.yml)\n\nRenders a [domhandler](https://github.com/fb55/domhandler) DOM node or an array of domhandler DOM nodes to a string.\n\n```js\nimport render from \"dom-serializer\";\n\n// OR\n\nconst render = require(\"dom-serializer\").default;\n```\n\n# API\n\n## `render`\n\n▸ **render**(`node`: Node \\| Node[], `options?`: [_Options_](#Options)): _string_\n\nRenders a DOM node or an array of DOM nodes to a string.\n\nCan be thought of as the equivalent of the `outerHTML` of the passed node(s).\n\n#### Parameters:\n\n| Name      | Type                               | Default value | Description                    |\n| :-------- | :--------------------------------- | :------------ | :----------------------------- |\n| `node`    | Node \\| Node[]                     | -             | Node to be rendered.           |\n| `options` | [_DomSerializerOptions_](#Options) | {}            | Changes serialization behavior |\n\n**Returns:** _string_\n\n## Options\n\n### `encodeEntities`\n\n• `Optional` **encodeEntities**: _boolean | \"utf8\"_\n\nEncode characters reserved in HTML or XML in text and attribute values.\n\nIf `xmlMode` is `true` or the value is not `'utf8'`, characters outside of the ASCII range will be encoded as well.\n\n> **Security:** Setting this to `false` disables encoding of `<`, `>`, and `&` in text and attribute values. This is intended for the round-trip case where the DOM was parsed with `decodeEntities: false`, so markup characters only exist as entity references. If the DOM contains raw markup characters (e.g., from a default-decoded parse, or from programmatic manipulation), they will be emitted literally — do not use this option with untrusted input unless you have validated the DOM yourself.\n\n**`default`** `decodeEntities`\n\n---\n\n### `decodeEntities`\n\n• `Optional` **decodeEntities**: _boolean_\n\nDefault for `encodeEntities`. Named to match the parser option of the same name so a single options object can be threaded through parse and serialize. Despite the name, on the serializer this option controls *encoding* — setting it to `false` carries the same security caveat as `encodeEntities: false`.\n\n**`default`** true\n\n---\n\n### `emptyAttrs`\n\n• `Optional` **emptyAttrs**: _boolean_\n\nPrint an empty attribute's value.\n\n**`default`** xmlMode\n\n**`example`** With <code>emptyAttrs: false</code>: <code>&lt;input checked&gt;</code>\n\n**`example`** With <code>emptyAttrs: true</code>: <code>&lt;input checked=\"\"&gt;</code>\n\n---\n\n### `selfClosingTags`\n\n• `Optional` **selfClosingTags**: _boolean_\n\nPrint self-closing tags for tags without contents. If `xmlMode` is set, this\nwill apply to all tags. Otherwise, only tags that are defined as self-closing\nin the HTML specification will be printed as such.\n\n**`default`** xmlMode\n\n**`example`** With <code>selfClosingTags: false</code>: <code>&lt;foo&gt;&lt;/foo&gt;&lt;br&gt;&lt;/br&gt;</code>\n\n**`example`** With <code>xmlMode: true</code> and <code>selfClosingTags: true</code>: <code>&lt;foo/&gt;&lt;br/&gt;</code>\n\n**`example`** With <code>xmlMode: false</code> and <code>selfClosingTags: true</code>: <code>&lt;foo&gt;&lt;/foo&gt;&lt;br /&gt;</code>\n\n---\n\n### `xmlMode`\n\n• `Optional` **xmlMode**: _boolean_ \\| _\"foreign\"_\n\nTreat the input as an XML document; enables the `emptyAttrs` and `selfClosingTags` options.\n\nIf the value is `\"foreign\"`, it will try to correct mixed-case attribute names.\n\n**`default`** false\n\n---\n\n## Ecosystem\n\n| Name                                                          | Description                                             |\n| ------------------------------------------------------------- | ------------------------------------------------------- |\n| [htmlparser2](https://github.com/fb55/htmlparser2)            | Fast & forgiving HTML/XML parser                        |\n| [domhandler](https://github.com/fb55/domhandler)              | Handler for htmlparser2 that turns documents into a DOM |\n| [domutils](https://github.com/fb55/domutils)                  | Utilities for working with domhandler's DOM             |\n| [css-select](https://github.com/fb55/css-select)              | CSS selector engine, compatible with domhandler's DOM   |\n| [cheerio](https://github.com/cheeriojs/cheerio)               | The jQuery API for domhandler's DOM                     |\n| [dom-serializer](https://github.com/cheeriojs/dom-serializer) | Serializer for domhandler's DOM                         |\n\n---\n\nLICENSE: MIT\n","publish_time":1777721042365,"_cnpm_publish_time":1777721042365,"dist-tags":{"latest":"3.1.1"}}