diff options
author | Florian Dold <florian.dold@gmail.com> | 2016-11-16 01:59:39 +0100 |
---|---|---|
committer | Florian Dold <florian.dold@gmail.com> | 2016-11-16 02:00:31 +0100 |
commit | bd65bb67e25a79b019d745b7262b2008ce2adb15 (patch) | |
tree | 89e1b032103a63737f1a703e6a943832ef261704 /node_modules/sax/examples/pretty-print.js | |
parent | f91466595b651721690133f58ab37f977539e95b (diff) |
incrementally verify denoms
The denominations are not stored in a separate object store.
Diffstat (limited to 'node_modules/sax/examples/pretty-print.js')
-rw-r--r-- | node_modules/sax/examples/pretty-print.js | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/node_modules/sax/examples/pretty-print.js b/node_modules/sax/examples/pretty-print.js deleted file mode 100644 index cd6aca9e1..000000000 --- a/node_modules/sax/examples/pretty-print.js +++ /dev/null @@ -1,74 +0,0 @@ -var sax = require("../lib/sax") - , printer = sax.createStream(false, {lowercasetags:true, trim:true}) - , fs = require("fs") - -function entity (str) { - return str.replace('"', '"') -} - -printer.tabstop = 2 -printer.level = 0 -printer.indent = function () { - print("\n") - for (var i = this.level; i > 0; i --) { - for (var j = this.tabstop; j > 0; j --) { - print(" ") - } - } -} -printer.on("opentag", function (tag) { - this.indent() - this.level ++ - print("<"+tag.name) - for (var i in tag.attributes) { - print(" "+i+"=\""+entity(tag.attributes[i])+"\"") - } - print(">") -}) - -printer.on("text", ontext) -printer.on("doctype", ontext) -function ontext (text) { - this.indent() - print(text) -} - -printer.on("closetag", function (tag) { - this.level -- - this.indent() - print("</"+tag+">") -}) - -printer.on("cdata", function (data) { - this.indent() - print("<![CDATA["+data+"]]>") -}) - -printer.on("comment", function (comment) { - this.indent() - print("<!--"+comment+"-->") -}) - -printer.on("error", function (error) { - console.error(error) - throw error -}) - -if (!process.argv[2]) { - throw new Error("Please provide an xml file to prettify\n"+ - "TODO: read from stdin or take a file") -} -var xmlfile = require("path").join(process.cwd(), process.argv[2]) -var fstr = fs.createReadStream(xmlfile, { encoding: "utf8" }) - -function print (c) { - if (!process.stdout.write(c)) { - fstr.pause() - } -} - -process.stdout.on("drain", function () { - fstr.resume() -}) - -fstr.pipe(printer) |