summaryrefslogtreecommitdiff
path: root/js/lib
diff options
context:
space:
mode:
authorJohn MacFarlane <jgm@berkeley.edu>2015-01-11 21:11:31 -0800
committerJohn MacFarlane <jgm@berkeley.edu>2015-01-11 21:11:55 -0800
commita0cbcefe82a6bff0a9b44550e22244d6d5d727c0 (patch)
tree8b1504dedba9684e0d67ea6dc95571af53aecef0 /js/lib
parent3b3c5c9502252a2ce13a7daffa80da2709d586e1 (diff)
A few changes to JS so its xml matches cmark's.
Always add '' as title property if title is not defined.
Diffstat (limited to 'js/lib')
-rw-r--r--js/lib/inlines.js6
-rw-r--r--js/lib/xml.js4
2 files changed, 7 insertions, 3 deletions
diff --git a/js/lib/inlines.js b/js/lib/inlines.js
index 4d49861..bcb9ee8 100644
--- a/js/lib/inlines.js
+++ b/js/lib/inlines.js
@@ -232,6 +232,7 @@ var parseAutolink = function(block) {
dest = m.slice(1, -1);
node = new Node('Link');
node.destination = 'mailto:' + encodeURI(unescape(dest));
+ node.title = '';
node.appendChild(text(dest));
block.appendChild(node);
return true;
@@ -239,6 +240,7 @@ var parseAutolink = function(block) {
dest = m.slice(1, -1);
node = new Node('Link');
node.destination = encodeURI(unescape(dest));
+ node.title = '';
node.appendChild(text(dest));
block.appendChild(node);
return true;
@@ -599,7 +601,7 @@ var parseCloseBracket = function(block) {
this.spnl() &&
// make sure there's a space before the title:
(reWhitespaceChar.test(this.subject.charAt(this.pos - 1)) &&
- (title = this.parseLinkTitle() || '') || true) &&
+ (title = this.parseLinkTitle()) || true) &&
this.spnl() &&
this.subject.charAt(this.pos) === ')') {
this.pos += 1;
@@ -635,7 +637,7 @@ var parseCloseBracket = function(block) {
if (matched) {
var node = new Node(is_image ? 'Image' : 'Link');
node.destination = dest;
- node.title = title;
+ node.title = title || '';
var tmp, next;
tmp = opener.node.next;
diff --git a/js/lib/xml.js b/js/lib/xml.js
index 30b44c8..056bcc5 100644
--- a/js/lib/xml.js
+++ b/js/lib/xml.js
@@ -111,7 +111,9 @@ var renderNodes = function(block) {
}
break;
case 'CodeBlock':
- attrs.push(['info', node.info]);
+ if (node.info) {
+ attrs.push(['info', node.info]);
+ }
break;
case 'Header':
attrs.push(['level', String(node.level)]);