//
// See README.md for how to run this file in the browser or in node.js.
//
-// This file exports a single useful function: parse_tml, and some constants
+// This file exports a single useful function: parse, and some constants
// (see the bottom of this file for those.)
//
// Call it like this:
//
// peach_parser.parse("<p><b>hi</p>", {fragment: "body"})
//
-// return value is an array of Nodes, see "class Node" below.
+// return value is an array of Nodes, A Node contains:
+// type: one of: "tag", "text", "comment", "doctype"
+// text: contents for text/comment nodes
+// attrs: object of attributes, eg {href: "#main"}
+// children: array of Nodes
+// namespace: one of: "html", "mathml", "svg"
+// parent: another Node or null
// This code is a work in progress, eg try search this file for "fixfull",
// "TODO" and "FIXME"
this.name = args.name != null ? args.name : '' // tag name
this.text = args.text != null ? args.text : '' // contents for text/comment nodes
this.attrs = args.attrs != null ? args.attrs : {}
- this.attrs_a = args.attr_k != null ? args.attr_k : [] // attrs in progress, TYPE_START_TAG only
this.children = args.children != null ? args.children : []
this.namespace = args.namespace != null ? args.namespace : NS_HTML
this.parent = args.parent != null ? args.parent : null
+ // private:
+ this.attrs_a = args.attr_k != null ? args.attr_k : [] // attrs in progress, TYPE_START_TAG only
this.token = args.token != null ? args.token : null
this.flags = args.flags != null ? args.flags : {}
if (args.id != null) {