{"name":"trumpet","version":"1.4.0","keywords":["html","streaming","parser","transform","selectors","css"],"author":{"url":"http://substack.net","name":"James Halliday","email":"mail@substack.net"},"license":"MIT","_id":"trumpet@1.4.0","maintainers":[{"name":"substack","email":"mail@substack.net"}],"bugs":{"url":"https://github.com/substack/node-trumpet/issues"},"dist":{"shasum":"5d4b826b244c118ab35c0f738b014789b01b9e61","tarball":"http://registry-npm.ywwl.com/trumpet/download/trumpet-1.4.0.tgz","integrity":"sha512-/vZDO3cC0YJk4dB9JFnWrlarQcTIn+nawRz7m7g32SdXXrDR7fxv7YEuORJbYAsO/yX1sdUcgd0L9naJXOJiuA==","signatures":[{"sig":"MEYCIQCyoSqXBuZNLeocJDDp2PuvnpMPR6WF09lnADH4CDKg+QIhAOR/IMGV61zJnJlPQGnFmtdeJi2QcLbe+TSK5ECzJJRe","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"size":10938,"noattachment":false,"key":"/trumpet/-/trumpet-1.4.0.tgz"},"main":"index.js","_from":".","engine":{"node":">=0.4"},"scripts":{"test":"tap test/*.js"},"_npmUser":{"name":"substack","email":"mail@substack.net"},"repository":{"url":"http://github.com/substack/node-trumpet.git","type":"git"},"_npmVersion":"1.3.0","description":"parse and transform streaming html using css selectors","directories":{},"dependencies":{"ent":"~0.0.5","sax":"~0.5.4","buffers":"~0.1.1","through":"~2.3.4","duplexer":"~0.1.1","inherits":"~2.0.0"},"devDependencies":{"tap":"~0.4.0","tape":"~1.0.4","concat-stream":"~1.0.0"},"readme":"# trumpet\n\nparse and transform streaming html using css selectors\n\n[![build status](https://secure.travis-ci.org/substack/node-trumpet.png)](http://travis-ci.org/substack/node-trumpet)\n\n![trumpet](http://substack.net/images/trumpet.png)\n\n# example\n\n## table\n\ninput html:\n\n``` html\n<table>\n  <tbody>blah blah blah</tbody>\n  <tr><td>there</td></tr>\n  <tr><td>it</td></tr>\n  <tr><td>is</td></tr>\n</table>\n```\n\n``` js\nvar trumpet = require('trumpet');\nvar tr = trumpet();\ntr.pipe(process.stdout);\n \nvar ws = tr.select('tbody').createWriteStream();\nws.end('<tr><td>rawr</td></tr>');\n\nvar fs = require('fs');\nfs.createReadStream(__dirname + '/html/table.html').pipe(tr);\n```\n\noutput:\n\n``` html\n<table>\n  <tbody><tr><td>rawr</td></tr></tbody>\n  <tr><td>there</td></tr>\n  <tr><td>it</td></tr>\n  <tr><td>is</td></tr>\n</table>\n```\n\n## read all\n\ninput html:\n\n``` html\n<html>\n  <head>\n    <title>beep</title>\n  </head>\n  <body>\n    <div class=\"a\">¡¡¡</div>\n    <div class=\"b\">\n      <span>tacos</span>\n      <span> y </span>\n      <span>burritos</span>\n    </div>\n    <div class=\"a\">!!!</div>\n  </body>\n</html>\n```\n\n``` js\nvar trumpet = require('trumpet');\nvar tr = trumpet();\n\ntr.selectAll('.b span', function (span) {\n    span.createReadStream().pipe(process.stdout);\n});\n\nvar fs = require('fs');\nfs.createReadStream(__dirname + '/html/read_all.html').pipe(tr);\n```\n\noutput:\n\n``` html\ntacos y burritos\n```\n\n# methods\n\n``` js\nvar trumpet = require('trumpet')\n```\n\n## var tr = trumpet(opts)\n\nCreate a new trumpet stream. This stream is readable and writable.\nPipe an html stream into `tr` and get back a transformed html stream.\n\nParse errors are emitted by `tr` in an `'error'` event.\n\n## var elem = tr.select(selector)\n\nReturn a result object `elem` for the first element matching `selector`.\n\n## tr.selectAll(selector, function (elem) {})\n\nGet a result object `elem` for every element matching `selector`.\n\n## elem.getAttribute(name, cb)\n\nWhen the selector for `elem` matches, query the case-insensitive attribute\ncalled `name` with `cb(value)`.\n\nReturns `elem`.\n\n## elem.getAttributes(name, cb)\n\nGet all the elements in `cb(attributes)` as an object `attributes` with\nlower-case keys.\n\nReturns `elem`.\n\n## elem.setAttribute(name, value)\n\nWhen the selector for `elem` matches, replace the case-insensitive attribute\ncalled `name` with `value`.\n\nIf the attribute doesn't exist, it will be created in the output stream.\n\nReturns `elem`.\n\n## elem.removeAttribute(name)\n\nWhen the selector for `elem` matches, remove the attribute called `name` if it\nexists.\n\nReturns `elem`.\n\n## elem.createReadStream(opts)\n\nCreate a new readable stream with the inner html content under `elem`.\n\nTo use the outer html content instead of the inner, set `opts.outer` to `true`.\n\n## elem.createWriteStream(opts)\n\nCreate a new write stream to replace the inner html content under `elem`.\n\nTo use the outer html content instead of the inner, set `opts.outer` to `true`.\n\n## elem.createStream(opts)\n\nCreate a new readable writable stream that outputs the content under `elem` and\nreplaces the content with the data written to it.\n\nTo use the outer html content instead of the inner, set `opts.outer` to `true`.\n\n## tr.createStream(sel, opts)\n\nShort-hand for `tr.select(sel).createStream(opts)`.\n\n## tr.createReadStream(sel, opts)\n\nShort-hand for `tr.select(sel).createReadStream(opts)`.\n\n## tr.createWriteStream(sel, opts)\n\nShort-hand for `tr.select(sel).createWriteStream(opts)`.\n\n# attributes\n\n## elem.name\n\nThe element name as a lower-case string. For example: `'div'`.\n\n# selector syntax\n\nPresently these [css selectors](http://www.w3.org/TR/CSS2/selector.html) work:\n\n* *\n* E\n* E F\n* E > F\n* E + F\n* E.class\n* E#id\n* E[attr=value]\n* E[attr~=search]\n* E[attr|=prefix]\n* E[attr^=prefix]\n* E[attr$=suffix]\n* E[attr*=search]\n\n# install\n\nWith [npm](http://npmjs.org) do:\n\n```\nnpm install trumpet\n```\n\n# license\n\nMIT\n","publish_time":1373151518894,"_cnpm_publish_time":1373151518894,"dist-tags":{"latest":"1.7.2"}}