From aac776b1711d1e286812035a28108c622e73994a Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 13 Oct 2015 22:10:42 +0100 Subject: Add simplification of nodes --- lib/html/index.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'lib/html/index.js') diff --git a/lib/html/index.js b/lib/html/index.js index f9e957a..41d348f 100644 --- a/lib/html/index.js +++ b/lib/html/index.js @@ -1,5 +1,17 @@ -var ast = require("./ast.js"); +var ast = require("./ast"); exports.fragment = ast.fragment; exports.element = ast.element; +exports.elementWithTag = ast.elementWithTag; exports.text = ast.text; + +function pathToNode(path, children) { + var result = ast.fragment(children); + for (var index = path.length - 1; index >= 0; index--) { + result = ast.elementWithTag(path[index], [result]); + } + return result; +} + +exports.pathToNode = pathToNode; +exports.simplify = require("./simplify"); -- cgit v1.2.3