aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--js/lib/xml.js76
1 files changed, 50 insertions, 26 deletions
diff --git a/js/lib/xml.js b/js/lib/xml.js
index cb59d7b..ea98d82 100644
--- a/js/lib/xml.js
+++ b/js/lib/xml.js
@@ -61,49 +61,73 @@ var renderNodes = function(block) {
if (options.time) { console.time("rendering"); }
+ buffer += '<?xml version="1.0" encoding="UTF-8"?>\n';
+ buffer += '<!DOCTYPE CommonMark SYSTEM "CommonMark.dtd">\n';
+
while ((event = walker.next())) {
entering = event.entering;
node = event.node;
+
+ if (node.t === '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 = node.t.toLowerCase();
- attrs = [];
+ if (entering) {
+
+ attrs = [];
+
+ if (node.list_data) {
+ var data = node.list_data;
+ if (data.type) {
+ attrs.push(['type', data.type.toLowerCase()]);
+ }
+ if (data.start) {
+ attrs.push(['start', String(data.start)]);
+ }
+ if (data.tight) {
+ attrs.push(['tight', (data.tight ? 'true' : 'false')]);
+ }
+ if (data.delimiter) {
+ var delimword = '';
+ if (data.delimiter === '.') {
+ delimword = 'period';
+ } else {
+ delimword = 'paren';
+ }
+ attrs.push(['delimiter', delimword]);
+ }
+ }
- if (node.list_data) {
- var data = node.list_data;
- if (data.type) {
- attrs.push(['type', data.type.toLowerCase()]);
+ if (node.info) {
+ attrs.push(['info', node.info]);
}
- if (data.start) {
- attrs.push(['start', String(data.start)]);
+ if (node.level) {
+ attrs.push(['level', String(node.level)]);
}
- if (data.tight) {
- attrs.push(['tight', (data.tight ? 'true' : 'false')]);
+ if (node.url) {
+ attrs.push(['url', node.url]);
}
- if (data.delimiter) {
- var delimword = '';
- if (data.delimiter === '.') {
- delimword = 'period';
- } else {
- delimword = 'paren';
- }
- attrs.push(['delimiter', delimword]);
+ if (node.title) {
+ attrs.push(['title', node.title]);
}
- }
- if (options.sourcepos) {
- var pos = node.sourcepos;
- if (pos) {
- attrs.push(['data-sourcepos', String(pos[0][0]) + ':' +
- String(pos[0][1]) + '-' + String(pos[1][0]) + ':' +
- String(pos[1][1])]);
+ if (options.sourcepos) {
+ var pos = node.sourcepos;
+ if (pos) {
+ attrs.push(['data-sourcepos', String(pos[0][0]) + ':' +
+ String(pos[0][1]) + '-' + String(pos[1][0]) + ':' +
+ String(pos[1][1])]);
+ }
}
- }
- if (entering) {
+
+
cr();
out(tag(tagname, attrs, selfClosing));
if (container) {