{"name":"@emmetio/html-matcher","version":"1.2.1","description":"Minimalistic and ultra-fast HTML parser & matcher","main":"./dist/html-matcher.cjs.js","module":"./dist/html-matcher.es.js","types":"./dist/index.d.ts","dependencies":{"@emmetio/scanner":"0.0.7"},"devDependencies":{"@types/mocha":"^7.0.2","@types/node":"^12.7.5","mocha":"^7.1.1","rollup":"^2.6.0","rollup-plugin-node-resolve":"^5.2.0","rollup-plugin-typescript2":"^0.27.0","ts-node":"^8.8.2","tslint":"^6.1.1","typescript":"^3.8.3"},"scripts":{"test":"mocha","lint":"tslint ./src/*.ts","build":"rollup -c","clean":"rm -rf ./dist","prepare":"npm run lint && npm test && npm run clean && npm run build"},"repository":{"type":"git","url":"git+https://github.com/emmetio/html-matcher.git"},"keywords":[],"author":{"name":"Sergey Chikuyonok","email":"serge.che@gmail.com"},"license":"ISC","bugs":{"url":"https://github.com/emmetio/html-matcher/issues"},"homepage":"https://github.com/emmetio/html-matcher#readme","directories":{"test":"test"},"mocha":{"require":"ts-node/register","spec":"./test/*.ts"},"gitHead":"215e0c2488e7b33df1a8e69649eef46106a75894","_id":"@emmetio/html-matcher@1.2.1","_nodeVersion":"12.14.1","_npmVersion":"6.13.4","dist":{"integrity":"sha512-oMSpalt/v4ggjBr8LCVtlHH2AKaDPtkvewRjNSb9tWAMzT0Qv748hklhDkn9GBXei+Fj/Md/GjMd8f8ROHO5Hg==","shasum":"1f189508bf60144a845c7fc868f6a0b15443fbd1","tarball":"http://registry-npm.ywwl.com/@emmetio/html-matcher/download/@emmetio/html-matcher-1.2.1.tgz","fileCount":11,"unpackedSize":134685,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJekhLYCRA9TVsSAnZWagAA4VMP/2wSt3yGtK/WCMsNMfQN\nqy91QBcMo5sIuCju+KXa3oo3nQi1FXVqXzE2sjAy8PGcp1fUgsJl70GwtEXC\nthvhxKHfPAMWQ6uq0tZnqosguphPUKeXRSELkIea9uNSgGT2t/c/Ftu3LbRg\nlh+8PamJLP2fivfEo2L+GZPccEHs5gKmj0+NxV+GdtzbXN6tRgt4uWvEG59h\nqvVisAbZg1aiQTGMGsO+zkKZYWHfjvhaihMoqXdCr1TlGS/M0dXBbhNcAhag\n/LPWVbvCxWQIYcj3jIo3BYF1/QqT2WLxw5QmYSqpomqmnVVPNkhHf7RKr/Pn\nzWOnx1CELz1kXU74rXx7JUy1/BqnIxjXV5yAORmLjdT+R5BCBjb0Z03aakmp\nWXmMYbyUz/adqLpczbJVWfYAvtr8KHTnz5gwzv5040iRNc9F7JHbXFWg9hC3\n2cwwXWOuORxdFP31V2VRqOuzvfcEbUa4QOrz7lrR4MtcvIfgeB6MfylrURRr\nRFRsQ2K2/5w5sDYcJJHsZ/nmOSz8wGw2HabnDwZRnLyjlEaUEk9Eg7wRiByn\nMRFCueaAUkrGXFZqssWqB297fv05KoK1OaqUrrTJ0KZYXJtKqs3s+wJFNbC/\ny1/rpBEa3SaXzB7iFTQwiTqeMbWkSpP5Jqja7eZcennSD3vlnOZAzskQk8bj\nv0L2\r\n=YgCo\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIHjjjDYAGTghi8B4gEZTnihUA/vkWRRIL/tshOvIngN2AiAPVXtOLlEHE7QNvVpqxoz0dDb9SxGsNoAtwY6nVPy38w=="}],"size":24808,"noattachment":false,"key":"/@emmetio/html-matcher/-/@emmetio/html-matcher-1.2.1.tgz"},"maintainers":[{"email":"info@emmet.io","name":"emmetio-user"},{"email":"serge.che@gmail.com","name":"serge.che"}],"_npmUser":{"name":"serge.che","email":"serge.che@gmail.com"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/html-matcher_1.2.1_1586631383495_0.8278090003455385"},"_hasShrinkwrap":false,"readme":"# Small and fast HTML matcher\n\nFinds matching opening and closing tag pair for given location in HTML/XML source:\n\n```js\nimport match from '@emmetio/html-matcher';\n\nconst content = '<div><a href=\"http://emmet.io\">Example</a></div>';\n\n// Find tag pair at character 35\nconst tag = match(content, 35);\n\nconsole.log(tag.name); // Name of matched tag: \"a\"\nconsole.log(tag.open); // Range of opening tag: [5, 31]\nconsole.log(tag.end); // Range of closing tag: [38, 42]\n\n// List of attributes found in opening tag\nconsole.log(tag.attributes);\n```\n\nBy default, matcher works in HTML, which means if it finds tag name which is known to be empty (for example, `<img>`) it will not search for it’s closing part. However, such behavior might be unexpected for XML syntaxes where all tags should be either self-closed or provide closing part. In this case, you should pass `xml: true` option to properly handle XML mode:\n\n```js\nimport match from '@emmetio/html-matcher';\n\nconst content = '<div><img>Caption</img></div>';\nconst html = match(content, 8);\nconst xml = match(content, 8, { xml: true });\n\nconsole.log(html.name); // \"img\"\nconsole.log(html.open); // [5, 10]\nconsole.log(html.close); // undefined\n\nconsole.log(xml.name); // \"img\"\nconsole.log(xml.open); // [5, 10]\nconsole.log(xml.close); // [17, 23]\n```\n\n## Special tags\n\nIn HTML, some tags has special meaning. For example, a `<script>` tag: its contents should be completely ignored until we find closing `</script>` tag. But, if `<script>` tag contains unknown `type` attribute value, we should consider it as a regular tag.  By default, matcher understands `script` and `style` tags as “special” but you can override them with `special` option:\n\n```js\nimport match from '@emmetio/html-matcher';\n\n// Treat `<foo-bar>` tag as ”special”: skip its content until `</foo-bar>`. Note that this option overwrites default value with `['script', 'style']` value\nmatch('...', 10, { special: { 'foo-bar': null } });\n```\n\nThe `special` option is an object where key is a tag name and value is an array of `type` attribute values which, if present in tag, will make it special. If array is not provided, all instances of tag with given name will be considered as special.\n","publish_time":1586631383650,"_cnpm_publish_time":1586631383650,"dist-tags":{"latest":"1.3.0"}}