{"_id":"posthtml-parser@0.13.0","bugs":{"url":"https://github.com/posthtml/posthtml-parser/issues"},"dist":{"shasum":"ea2b21ddc369cc5be1effd60ba3c52c5f9896bb7","tarball":"http://registry-npm.ywwl.com/posthtml-parser/download/posthtml-parser-0.13.0.tgz","fileCount":9,"integrity":"sha512-zEppd7gKiuXTnh+lEyEpUJ39GrSiM7vO3ymsHriGi7d8RHUXFgBiHbE8WAV5KRgGlQDGceM0wp9LB3GLEeLPLw==","signatures":[{"sig":"MEYCIQCqbXyo74yR5+qL4cXACCCfvlZnf7OE0ATHSYssWNk4EgIhAMhGUqrjxwpOYPXhzKopqKPKuLNNjBRQXp5Vq4S/eS/e","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCtAJ+4/OT26YIlHQ6wFrTlzs+Noie9vhKNN6aWfh8uXgIgPLBxYzJL9zPvGFJiP9MrAlPVbGtKBBzqECz9RevvDRU="}],"unpackedSize":31262,"size":8294,"noattachment":false,"key":"/posthtml-parser/-/posthtml-parser-0.13.0.tgz"},"main":"dist","name":"posthtml-parser","types":"dist/index.d.ts","author":{"name":"Ivan Voischev","email":"voischev.ivan@ya.ru"},"engines":{"node":"^20.19.0 || >=22.12.0"},"gitHead":"9ead2632b1a8aa81217ac29b0c33feb8d9524640","license":"MIT","scripts":{"dev":"tsc --watch","lint":"eslint .","test":"npm run build && npm run test:coverage","build":"rm -rf dist && tsc","check":"npm run build && npm run lint && npm run typecheck && npm run typecheck:minimum && npm run test:coverage && npm run test:package","prepare":"npm run build","test:unit":"node --test test/core.test.cjs","typecheck":"tsc --noEmit && tsc --noEmit -p test/types/tsconfig.json","test:package":"node test/package.cjs","test:coverage":"c8 node --test test/core.test.cjs","prepublishOnly":"npm run check","typecheck:minimum":"npm exec --yes --package=typescript@5.3.3 -- tsc --noEmit -p test/types/tsconfig.json"},"version":"0.13.0","_npmUser":{"name":"voischev","email":"voischev.ivan@ya.ru"},"homepage":"https://github.com/posthtml/posthtml-parser#readme","keywords":["html","xml","parser","posthtml","posthtmltree"],"repository":{"url":"git+https://github.com/posthtml/posthtml-parser.git","type":"git"},"_npmVersion":"11.19.1","description":"Parse HTML/XML to PostHTMLTree","directories":{},"maintainers":[{"name":"voischev","email":"voischev.ivan@ya.ru"},{"name":"mrmlnc","email":"dmalinochkin@rambler.ru"},{"name":"scrum","email":"scrum@list.ru"}],"_nodeVersion":"24.22.1","contributors":[{"name":"Ivan Voischev","email":"voischev.ivan@ya.ru"},{"name":"Ivan Demidov","email":"scrum@posthtml.org"}],"dependencies":{"htmlparser2":"^12.0.0"},"_hasShrinkwrap":false,"devDependencies":{"c8":"^12.0.0","eslint":"^10.13.0","globals":"^17.13.0","@eslint/js":"^10.0.1","typescript":"~6.0.3","@types/node":"^20.19.0","typescript-eslint":"^8.72.1"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/posthtml-parser_0.13.0_1793286347291_0.17372511490745113"},"readme":"# PostHTML Parser\n\nParse HTML/XML into a [PostHTML AST](#posthtml-ast-format) using [htmlparser2](https://github.com/fb55/htmlparser2).\n\n## Installation\n\nRequires Node.js `^20.19.0 || >=22.12.0`. These versions support synchronous CommonJS loading of the ESM-only `htmlparser2` backend. Both `require()` and native ESM imports expose the synchronous `parser` API.\n\nTypeScript consumers need TypeScript 5.3 or later.\n\n```sh\nnpm install posthtml-parser\n```\n\n## Usage\n\n```js\nimport { parser } from \"posthtml-parser\";\n\nconst tree = parser('<a class=\"link\">Hello</a>');\nconsole.log(tree);\n```\n\nResult:\n\n```js\n[\n  {\n    tag: \"a\",\n    attrs: {\n      class: \"link\"\n    },\n    content: [\"Hello\"]\n  }\n]\n```\n\nCommonJS is supported too:\n\n```js\nconst { parser } = require(\"posthtml-parser\");\n```\n\n## PostHTML AST Format\n\nA tree is an array of strings and element objects. Elements have a `tag` and optional `attrs` and `content`; `content` is another tree. Comments and directives remain strings.\n\nValueless attributes are empty strings by default, or `true` with `recognizeNoValueAttribute`. Enabling `sourceLocations` adds a `location` with 1-based start/end line and column positions.\n\n## Options\n\nPass options as the second argument to `parser(html, options)`:\n\n| Option | Default | Description |\n| --- | --- | --- |\n| `directives` | `[]` | Extra directives with `name` (string or RegExp), `start`, and `end`. Doctypes are always included. |\n| `xmlMode` | `false` | Parse XML, including CDATA and self-closing tags. |\n| `decodeEntities` | `false` | Decode character entities, including text inside `textarea`. |\n| `lowerCaseTags` | `false` | Lowercase element names, including SVG names. |\n| `lowerCaseAttributeNames` | `false` | Lowercase attribute names. |\n| `recognizeCDATA` | `xmlMode` | Recognize CDATA in HTML mode; XML always recognizes it. |\n| `recognizeSelfClosing` | `xmlMode` | Recognize `<tag />` as a self-closing tag. |\n| `sourceLocations` | `false` | Add source positions to element nodes. |\n| `recognizeNoValueAttribute` | `false` | Represent valueless attributes as `true` instead of empty strings. |\n\nFor example, preserve a PHP directive:\n\n```js\nparser('<?php echo \"Hello\"; ?>', {\n  directives: [{ name: \"?php\", start: \"<\", end: \">\" }]\n});\n```\n\n## Contributing\n\nSee [contributing and release instructions](https://github.com/posthtml/posthtml-parser/blob/master/.github/CONTRIBUTING.md) for development commands, commit guidelines, and publishing.\n\nMaintainer: [Ivan Voischev](mailto:voischev.ivan@ya.ru).\n\n## License\n\n[MIT](license).\n","publish_time":1793286347393,"_cnpm_publish_time":1793286347393,"dist-tags":{"latest":"0.13.0"}}