{"_id":"posthtml-match-helper","_rev":"324061","name":"posthtml-match-helper","description":"A helper to expand CSS selectors into PostHTML matcher objects","dist-tags":{"latest":"1.0.1"},"maintainers":[{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"}],"time":{"modified":"2021-06-04T01:50:56.000Z","created":"2015-10-12T11:02:19.661Z","1.0.1":"2015-10-17T23:42:21.547Z","1.0.0":"2015-10-12T11:02:19.661Z"},"users":{},"author":{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/rasmusfl0e/posthtml-match-helper.git"},"versions":{"1.0.1":{"name":"posthtml-match-helper","version":"1.0.1","description":"A helper to expand CSS selectors into PostHTML matcher objects","keywords":["posthtml","posthtml-helper"],"main":"index.js","repository":{"type":"git","url":"git+https://github.com/rasmusfl0e/posthtml-match-helper.git"},"bugs":{"url":"https://github.com/rasmusfl0e/posthtml-match-helper/issues"},"author":{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"},"license":"ISC","peerDependencies":{"posthtml":">=0.5.0"},"gitHead":"053d0e791e2a26aabdf1a1ed180c37758c53f3e0","homepage":"https://github.com/rasmusfl0e/posthtml-match-helper#readme","_id":"posthtml-match-helper@1.0.1","scripts":{},"_shasum":"451253de8e5844a348e963ad5edd7769eb129513","_from":".","_npmVersion":"2.14.4","_nodeVersion":"4.1.1","_npmUser":{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"},"maintainers":[{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"}],"dist":{"shasum":"451253de8e5844a348e963ad5edd7769eb129513","size":2102,"noattachment":false,"key":"/posthtml-match-helper/-/posthtml-match-helper-1.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/posthtml-match-helper/download/posthtml-match-helper-1.0.1.tgz"},"directories":{},"publish_time":1445125341547,"_cnpm_publish_time":1445125341547,"_hasShrinkwrap":false},"1.0.0":{"name":"posthtml-match-helper","version":"1.0.0","description":"A helper to expand CSS selctors into PostHTML matcher objects","main":"index.js","repository":{"type":"git","url":"git+https://github.com/rasmusfl0e/posthtml-match-helper.git"},"bugs":{"url":"https://github.com/rasmusfl0e/posthtml-match-helper/issues"},"author":{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"},"license":"ISC","peerDependencies":{"posthtml":"^0.5.0"},"gitHead":"b58e3e52419b16a1d303b6e6f103b2dd12dcec45","homepage":"https://github.com/rasmusfl0e/posthtml-match-helper#readme","_id":"posthtml-match-helper@1.0.0","scripts":{},"_shasum":"0c6b6e8ea4bbd41985dface3845f8c46f2090041","_from":".","_npmVersion":"2.14.2","_nodeVersion":"4.0.0","_npmUser":{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"},"maintainers":[{"name":"rasmusfl0e","email":"rasmusfl0e@gmail.com"}],"dist":{"shasum":"0c6b6e8ea4bbd41985dface3845f8c46f2090041","size":2113,"noattachment":false,"key":"/posthtml-match-helper/-/posthtml-match-helper-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/posthtml-match-helper/download/posthtml-match-helper-1.0.0.tgz"},"directories":{},"publish_time":1444647739661,"_cnpm_publish_time":1444647739661,"_hasShrinkwrap":false}},"readme":"# posthtml-match-helper\n\n> A helper to expand CSS selectors into [PostHTML](https://github.com/posthtml/posthtml) matcher objects\n\nUsing the helper function supplied by this module you can turn simple CSS selectors into match objects that [posthtml match](https://github.com/posthtml/posthtml/blob/master/README.md#match) accepts.\n\nSupported features:\n\n* Tags: `\"div\"` returns `{tag: \"div\"}`.\n* Ids: `\"#bar\"` returns `{attrs: {id: \"bar\"}}`.\n* Classes: `.foo` returns `{attrs: { class: /(?:^|\\s)foo(?:\\\\s|$)/ }}`. Any number of classnames supported.\n* Attribute selectors: Any number of the standard [attribute selectors](https://developer.mozilla.org/en/docs/Web/CSS/Attribute_selectors) can be used<sup><a href=\"#attribute_selectors_footnote\">1</a></sup> including the following non-standard:\n   * `[attr!=value]`: Matches if the `attr` attribute value does not contain the `value`.\n* Multiple node selectors: `\"div, section\"` returns `[{tag: \"div\"}, {tag: \"span\"}]`.\n\n**<sup><a name=\"attribute_selectors_footnote\">1</a></sup>** Multiple attribute selectors for the same attribute are not supported (this includes mixing classnames and attribute selectors matching `class`).\n\nThe basic template for selectors (and order of features) looks like this:\n\n```js\n\"tag#id.class.name[attr*=value][otherattr^='start']\"\n```\n\n## Basic usage\n\n```js\nvar matchHelper = require(\"posthtml-match-helper\");\n\ntree.match(matchHelper(\"div.class\"), function (node) {\n\t// do stuff with matched node...\n});\n```\n\n## Advanced usage\n\n```js\nvar matchHelper = require(\"posthtml-match-helper\");\n\ntree.match(matchHelper(\"input.my-control[type!='radio'][checked], input[value^='foo'][checked]\"), function (node) {\n\t// do stuff with node that matched either of the selectors...\n});\n```\n\n## The helper function\n\n#### Arguments\n\n* `matcher` (string) - A CSS selector that describes the node you want to match in PostHTML.\n\n#### Returns\n\nA matcher object - or array of matcher objects.\n","_attachments":{},"homepage":"https://github.com/rasmusfl0e/posthtml-match-helper#readme","bugs":{"url":"https://github.com/rasmusfl0e/posthtml-match-helper/issues"},"license":"ISC"}