summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-11 21:04:45 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-11 21:04:45 -0800
commit3b3c5c9502252a2ce13a7daffa80da2709d586e1 (patch)
tree3133809d5a448dfd5045dc49313ef8a108606183 /js
parent5e2e9034f13438ad6286ab09d49cfe425f06090c (diff)
More xml.js improvements.
Diffstat (limited to 'js')
-rw-r--r--js/lib/xml.js37
1 files changed, 19 insertions, 18 deletions
diff --git a/js/lib/xml.js b/js/lib/xml.js
index c90704e..30b44c8 100644
--- a/js/lib/xml.js
+++ b/js/lib/xml.js
@@ -41,6 +41,7 @@ var renderNodes = function(block) {
var unescapedContents;
var container;
var selfClosing;
+ var nodetype;
var out = function(s) {
if (disableTags > 0) {
@@ -71,22 +72,24 @@ var renderNodes = function(block) {
while ((event = walker.next())) {
entering = event.entering;
node = event.node;
+ nodetype = node.t;
- if (node.t === 'ReferenceDef') {
+ if (nodetype === 'ReferenceDef') {
continue;
}
container = node.isContainer();
- selfClosing = node.t === 'HorizontalRule' || node.t === 'Hardbreak' ||
- node.t === 'Softbreak' || node.t === 'Image';
- unescapedContents = node.t === 'Html' || node.t === 'HtmlInline';
- tagname = toTagName(node.t);
+ selfClosing = nodetype === 'HorizontalRule' || nodetype === 'Hardbreak' ||
+ nodetype === 'Softbreak' || nodetype === 'Image';
+ unescapedContents = nodetype === 'Html' || nodetype === 'HtmlInline';
+ tagname = toTagName(nodetype);
if (entering) {
attrs = [];
- if (node.list_data) {
+ switch (nodetype) {
+ case 'List':
var data = node.list_data;
if (data.type !== undefined) {
attrs.push(['type', data.type.toLowerCase()]);
@@ -106,21 +109,21 @@ var renderNodes = function(block) {
}
attrs.push(['delimiter', delimword]);
}
- }
-
- if (node.info !== undefined) {
+ break;
+ case 'CodeBlock':
attrs.push(['info', node.info]);
- }
- if (node.level !== undefined) {
+ break;
+ case 'Header':
attrs.push(['level', String(node.level)]);
- }
- if (node.destination !== undefined) {
+ break;
+ case 'Link':
+ case 'Image':
attrs.push(['destination', node.destination]);
- }
- if (node.title !== undefined) {
attrs.push(['title', node.title]);
+ break;
+ default:
+ break;
}
-
if (options.sourcepos) {
var pos = node.sourcepos;
if (pos !== undefined) {
@@ -130,8 +133,6 @@ var renderNodes = function(block) {
}
}
-
-
cr();
out(tag(tagname, attrs, selfClosing));
if (container) {