Small updates from upstream markdown-js

This commit is contained in:
Robin Ward 2014-07-28 16:50:16 -04:00
parent e1be478ef4
commit f6a15893e4

View file

@ -473,8 +473,12 @@
delete attributes.src; delete attributes.src;
} }
for ( var a in attributes ) for ( var a in attributes ) {
tag_attrs += " " + a + '="' + escapeHTML( attributes[ a ] ) + '"'; var escaped = escapeHTML( attributes[ a ]);
if (escaped && escaped.length) {
tag_attrs += " " + a + '="' + escaped + '"';
}
}
// be careful about adding whitespace here for inline elements // be careful about adding whitespace here for inline elements
if ( tag === "img" || tag === "br" || tag === "hr" ) if ( tag === "img" || tag === "br" || tag === "hr" )
@ -577,7 +581,7 @@
jsonml[ 0 ] = "img"; jsonml[ 0 ] = "img";
// grab this ref and clean up the attribute node // grab this ref and clean up the attribute node
ref = references[ attrs.ref ]; var ref = references[ attrs.ref ];
// if the reference exists, make the link // if the reference exists, make the link
if ( ref ) { if ( ref ) {
@ -745,7 +749,8 @@
block_search: block_search:
do { do {
// Now pull out the rest of the lines // Now pull out the rest of the lines
var b = this.loop_re_over_block(re, block.valueOf(), function(m) { ret.push( m[1] ); }); var b = this.loop_re_over_block(
re, block.valueOf(), function( m ) { ret.push( m[1] ); } );
if ( b.length ) { if ( b.length ) {
// Case alluded to in first comment. push it back on as a new block // Case alluded to in first comment. push it back on as a new block
@ -1008,11 +1013,11 @@
} // tight_search } // tight_search
if ( li_accumulate.length ) { if ( li_accumulate.length ) {
var contents = this.processBlock(li_accumulate, []), var contents = this.processBlock(li_accumulate, []),
firstBlock = contents[0]; firstBlock = contents[0];
if (firstBlock) { if (firstBlock) {
firstBlock.shift(); firstBlock.shift();
contents.splice.apply(contents, [0, 1].concat(firstBlock)); contents.splice.apply(contents, [0, 1].concat(firstBlock));
add( last_li, loose, contents, nl ); add( last_li, loose, contents, nl );
@ -1042,11 +1047,11 @@
var next_block = next[0] && next[0].valueOf() || ""; var next_block = next[0] && next[0].valueOf() || "";
if ( next_block.match(is_list_re) ) { if ( next_block.match(is_list_re) ) {
block = next.shift(); block = next.shift();
// Check for an HR following a list: features/lists/hr_abutting // Check for an HR following a list: features/lists/hr_abutting
var hr = this.dialect.block.horizRule.apply(this, [block, next]); var hr = this.dialect.block.horizRule.call( this, block, next );
if ( hr ) { if ( hr ) {
ret.push.apply(ret, hr); ret.push.apply(ret, hr);
@ -1113,6 +1118,7 @@
// Strip off the leading "> " and re-process as a block. // Strip off the leading "> " and re-process as a block.
var input = block.replace( /^> ?/gm, "" ), var input = block.replace( /^> ?/gm, "" ),
old_tree = this.tree,
processedBlock = this.toTree( input, [ "blockquote" ] ), processedBlock = this.toTree( input, [ "blockquote" ] ),
attr = extract_attr( processedBlock ); attr = extract_attr( processedBlock );
@ -1213,7 +1219,7 @@
return out; return out;
}, },
// These characters are intersting elsewhere, so have rules for them so that // These characters are interesting elsewhere, so have rules for them so that
// chunks of plain text blocks don't include them // chunks of plain text blocks don't include them
"]": function () {}, "]": function () {},
"}": function () {}, "}": function () {},