summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-11 18:20:23 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-11 18:20:23 -0800
commiteea23326c89875d6737e6bbeec7f7b201ed36d03 (patch)
tree4f2d95d757adbb86deefd58ee3171d24fa0f23c4 /js
parentef487406436407320a54273d5668bf1520e08d67 (diff)
Handle more attributes with xml.js.
Diffstat (limited to 'js')
-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) {