summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2015-10-14 19:17:07 +0100
committerMichael Williamson <mike@zwobble.org>2015-10-14 19:17:07 +0100
commite0397dcd7f650e86898ceab97eedc5753494d9f5 (patch)
treee448fe8a0699e42756682d06a8b70e73a47c520e
parent46ad965f936563829a7c0549a5eb1af89155ee48 (diff)
Rename html.element to html.freshElement
-rw-r--r--lib/document-to-html.js24
-rw-r--r--lib/html/ast.js4
-rw-r--r--lib/html/index.js2
-rw-r--r--tests/html/ast.tests.js4
4 files changed, 17 insertions, 17 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js
index eef0f8e..f296c11 100644
--- a/lib/document-to-html.js
+++ b/lib/document-to-html.js
@@ -199,20 +199,20 @@ function DocumentConversion(options) {
}
function convertTable(element, messages, callback) {
- wrapChildren(element, "table", messages, callback);
+ wrapChildrenInFreshElement(element, "table", messages, callback);
}
function convertTableRow(element, messages, callback) {
- wrapChildren(element, "tr", messages, callback);
+ wrapChildrenInFreshElement(element, "tr", messages, callback);
}
function convertTableCell(element, messages, callback) {
- wrapChildren(element, "td", messages, callback);
+ wrapChildrenInFreshElement(element, "td", messages, callback);
}
- function wrapChildren(element, wrapElementName, messages, callback) {
+ function wrapChildrenInFreshElement(element, wrapElementName, messages, callback) {
convertElements(element.children, messages, function(error, children) {
- callback(null, Html.element(wrapElementName, {}, [
+ callback(null, Html.freshElement(wrapElementName, {}, [
Html.forceWrite,
Html.fragment(children)]));
});
@@ -227,7 +227,7 @@ function DocumentConversion(options) {
convertElements(notes, messages, function(error, notesNodes) {
callback(null, Html.fragment([
Html.fragment(children),
- Html.element("ol", {}, notesNodes)]));
+ Html.freshElement("ol", {}, notesNodes)]));
});
});
},
@@ -243,19 +243,19 @@ function DocumentConversion(options) {
var href = element.anchor ? "#" + htmlId(element.anchor) : element.href;
convertElements(element.children, messages, function(error, children) {
- callback(null, Html.element("a", {href: href}, children));
+ callback(null, Html.freshElement("a", {href: href}, children));
});
},
"bookmarkStart": function(element, messages, callback) {
- callback(null, Html.element("a", {
+ callback(null, Html.freshElement("a", {
id: htmlId(element.name)
}, [Html.forceWrite]));
},
"noteReference": function(element, messages, callback) {
noteReferences.push(element);
- callback(null, Html.element("sup", {}, [
- Html.element("a", {
+ callback(null, Html.freshElement("sup", {}, [
+ Html.freshElement("a", {
href: "#" + noteHtmlId(element),
id: noteRefHtmlId(element)
}, [Html.text("[" + (noteNumber++) + "]")])
@@ -263,12 +263,12 @@ function DocumentConversion(options) {
},
"note": function(element, messages, callback) {
convertElements(element.body, messages, function(error, children) {
- callback(null, Html.element("li", {id: noteHtmlId(element)}, [
+ callback(null, Html.freshElement("li", {id: noteHtmlId(element)}, [
Html.fragment(children),
Html.elementWithTag(htmlPaths.element("p", {}, {fresh: false}), [
Html.text(" "),
- Html.element("a", {href: "#" + noteRefHtmlId(element)}, [Html.text("↑")]),
+ Html.freshElement("a", {href: "#" + noteRefHtmlId(element)}, [Html.text("↑")]),
])
]));
diff --git a/lib/html/ast.js b/lib/html/ast.js
index 6056f5c..30e65c7 100644
--- a/lib/html/ast.js
+++ b/lib/html/ast.js
@@ -16,7 +16,7 @@ function nonFreshElement(tagName, attributes, children) {
children);
}
-function element(tagName, attributes, children) {
+function freshElement(tagName, attributes, children) {
return elementWithTag(
htmlPaths.element(tagName, attributes, {fresh: true}),
children);
@@ -67,7 +67,7 @@ function collapseFragments(elements) {
}
exports.fragment = fragment;
-exports.element = element;
+exports.freshElement = freshElement;
exports.nonFreshElement = nonFreshElement;
exports.elementWithTag = elementWithTag;
exports.selfClosingElement = selfClosingElement;
diff --git a/lib/html/index.js b/lib/html/index.js
index 6de2a6e..8fa1fcf 100644
--- a/lib/html/index.js
+++ b/lib/html/index.js
@@ -1,7 +1,7 @@
var ast = require("./ast");
exports.fragment = ast.fragment;
-exports.element = ast.element;
+exports.freshElement = ast.freshElement;
exports.nonFreshElement = ast.nonFreshElement;
exports.elementWithTag = ast.elementWithTag;
exports.selfClosingElement = ast.selfClosingElement;
diff --git a/tests/html/ast.tests.js b/tests/html/ast.tests.js
index c2a1479..04db5f7 100644
--- a/tests/html/ast.tests.js
+++ b/tests/html/ast.tests.js
@@ -13,8 +13,8 @@ describe("HTML ast", function() {
test("children of elements are collapsed", function() {
assert.deepEqual(
- html.element("p", {}, [html.text("Hello")]),
- html.element("p", {}, [html.fragment([html.text("Hello")])]));
+ html.freshElement("p", {}, [html.text("Hello")]),
+ html.freshElement("p", {}, [html.fragment([html.text("Hello")])]));
});
});