X-Git-Url: https://jasonwoof.com/gitweb/?p=peach-html5-editor.git;a=blobdiff_plain;f=parser.js;h=7df5113072058fd1dd8b3c589b2e53b477079b5f;hp=ea87c858bd44622989ace630e8cfb56fe620cea4;hb=80153058975905b53418f34498b799922f3def07;hpb=5aef791edd38fb3d70a71266ad0b42cf9fb45593 diff --git a/parser.js b/parser.js index ea87c85..7df5113 100644 --- a/parser.js +++ b/parser.js @@ -41,7 +41,7 @@ // // 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: @@ -52,7 +52,13 @@ // // peach_parser.parse("

hi

", {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" @@ -145,10 +151,11 @@ function Node (type, args) { 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) {