vendor/assets/javascripts/marked.js in marked-rails-0.2.9.0 vs vendor/assets/javascripts/marked.js in marked-rails-0.2.10.0
- old
+ new
@@ -15,11 +15,11 @@
code: /^( {4}[^\n]+\n*)+/,
fences: noop,
hr: /^( *[-*_]){3,} *(?:\n+|$)/,
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/,
nptable: noop,
- lheading: /^([^\n]+)\n *(=|-){3,} *\n*/,
+ lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
blockquote: /^( *>[^\n]+(\n[^\n]+)*\n*)+/,
list: /^( *)(bull) [\s\S]+?(?:hr|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
html: /^ *(?:comment|closed|closing) *(?:\n{2,}|\s*$)/,
def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/,
table: noop,
@@ -73,11 +73,13 @@
fences: /^ *(`{3,}|~{3,}) *(\S+)? *\n([\s\S]+?)\s*\1 *(?:\n+|$)/,
paragraph: /^/
});
block.gfm.paragraph = replace(block.paragraph)
- ('(?!', '(?!' + block.gfm.fences.source.replace('\\1', '\\2') + '|')
+ ('(?!', '(?!'
+ + block.gfm.fences.source.replace('\\1', '\\2') + '|'
+ + block.list.source.replace('\\1', '\\3') + '|')
();
/**
* GFM + Tables Block Grammar
*/
@@ -306,11 +308,11 @@
}
// Determine whether the next list item belongs here.
// Backpedal if it does not belong in this list.
if (this.options.smartLists && i !== l - 1) {
- b = block.bullet.exec(cap[i+1])[0];
+ b = block.bullet.exec(cap[i + 1])[0];
if (bull !== b && !(bull.length > 1 && b.length > 1)) {
src = cap.slice(i + 1).join('\n') + src;
i = l - 1;
}
}
@@ -318,11 +320,11 @@
// Determine whether item is loose or not.
// Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
// for discount behavior.
loose = next || /\n\n(?!\s*$)/.test(item);
if (i !== l - 1) {
- next = item[item.length-1] === '\n';
+ next = item.charAt(item.length - 1) === '\n';
if (!loose) loose = next;
}
this.tokens.push({
type: loose
@@ -350,11 +352,11 @@
src = src.substring(cap[0].length);
this.tokens.push({
type: this.options.sanitize
? 'paragraph'
: 'html',
- pre: cap[1] === 'pre' || cap[1] === 'script',
+ pre: cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style',
text: cap[0]
});
continue;
}
@@ -405,11 +407,11 @@
// top-level paragraph
if (top && (cap = this.rules.paragraph.exec(src))) {
src = src.substring(cap[0].length);
this.tokens.push({
type: 'paragraph',
- text: cap[1][cap[1].length-1] === '\n'
+ text: cap[1].charAt(cap[1].length - 1) === '\n'
? cap[1].slice(0, -1)
: cap[1]
});
continue;
}
@@ -452,12 +454,12 @@
br: /^ {2,}\n(?!\s*$)/,
del: noop,
text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/
};
-inline._inside = /(?:\[[^\]]*\]|[^\]]|\](?=[^\[]*\]))*/;
-inline._href = /\s*<?([^\s]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
+inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/;
+inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/;
inline.link = replace(inline.link)
('inside', inline._inside)
('href', inline._href)
();
@@ -565,11 +567,11 @@
// autolink
if (cap = this.rules.autolink.exec(src)) {
src = src.substring(cap[0].length);
if (cap[2] === '@') {
- text = cap[1][6] === ':'
+ text = cap[1].charAt(6) === ':'
? this.mangle(cap[1].substring(7))
: this.mangle(cap[1]);
href = this.mangle('mailto:') + text;
} else {
text = escape(cap[1]);
@@ -620,11 +622,11 @@
|| (cap = this.rules.nolink.exec(src))) {
src = src.substring(cap[0].length);
link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
link = this.links[link.toLowerCase()];
if (!link || !link.href) {
- out += cap[0][0];
+ out += cap[0].charAt(0);
src = cap[0].substring(1) + src;
continue;
}
out += this.outputLink(cap, link);
continue;
@@ -692,11 +694,11 @@
/**
* Compile Link
*/
InlineLexer.prototype.outputLink = function(cap, link) {
- if (cap[0][0] !== '!') {
+ if (cap[0].charAt(0) !== '!') {
return '<a href="'
+ escape(link.href)
+ '"'
+ (link.title
? ' title="'
@@ -726,13 +728,21 @@
*/
InlineLexer.prototype.smartypants = function(text) {
if (!this.options.smartypants) return text;
return text
+ // em-dashes
.replace(/--/g, '\u2014')
- .replace(/'([^']*)'/g, '\u2018$1\u2019')
- .replace(/"([^"]*)"/g, '\u201C$1\u201D')
+ // opening singles
+ .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
+ // closing singles & apostrophes
+ .replace(/'/g, '\u2019')
+ // opening doubles
+ .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
+ // closing doubles
+ .replace(/"/g, '\u201d')
+ // ellipses
.replace(/\.{3}/g, '\u2026');
};
/**
* Mangle Links
@@ -801,11 +811,11 @@
/**
* Preview Next Token
*/
Parser.prototype.peek = function() {
- return this.tokens[this.tokens.length-1] || 0;
+ return this.tokens[this.tokens.length - 1] || 0;
};
/**
* Parse Text Tokens
*/
@@ -833,11 +843,13 @@
return '<hr>\n';
}
case 'heading': {
return '<h'
+ this.token.depth
- + '>'
+ + ' id="'
+ + this.token.text.toLowerCase().replace(/[^\w]+/g, '-')
+ + '">'
+ this.inline.output(this.token.text)
+ '</h'
+ this.token.depth
+ '>\n';
}
@@ -875,26 +887,30 @@
// header
body += '<thead>\n<tr>\n';
for (i = 0; i < this.token.header.length; i++) {
heading = this.inline.output(this.token.header[i]);
- body += this.token.align[i]
- ? '<th align="' + this.token.align[i] + '">' + heading + '</th>\n'
- : '<th>' + heading + '</th>\n';
+ body += '<th';
+ if (this.token.align[i]) {
+ body += ' style="text-align:' + this.token.align[i] + '"';
+ }
+ body += '>' + heading + '</th>\n';
}
body += '</tr>\n</thead>\n';
// body
body += '<tbody>\n'
for (i = 0; i < this.token.cells.length; i++) {
row = this.token.cells[i];
body += '<tr>\n';
for (j = 0; j < row.length; j++) {
cell = this.inline.output(row[j]);
- body += this.token.align[j]
- ? '<td align="' + this.token.align[j] + '">' + cell + '</td>\n'
- : '<td>' + cell + '</td>\n';
+ body += '<td';
+ if (this.token.align[j]) {
+ body += ' style="text-align:' + this.token.align[j] + '"';
+ }
+ body += '>' + cell + '</td>\n';
}
body += '</tr>\n';
}
body += '</tbody>\n';
@@ -1025,11 +1041,11 @@
if (!callback) {
callback = opt;
opt = null;
}
- if (opt) opt = merge({}, marked.defaults, opt);
+ opt = merge({}, marked.defaults, opt || {});
var highlight = opt.highlight
, tokens
, pending
, i = 0;
@@ -1040,17 +1056,13 @@
return callback(e);
}
pending = tokens.length;
- var done = function(hi) {
+ var done = function() {
var out, err;
- if (hi !== true) {
- delete opt.highlight;
- }
-
try {
out = Parser.parse(tokens, opt);
} catch (e) {
err = e;
}
@@ -1061,13 +1073,15 @@
? callback(err)
: callback(null, out);
};
if (!highlight || highlight.length < 3) {
- return done(true);
+ return done();
}
+ delete opt.highlight;
+
if (!pending) return done();
for (; i < tokens.length; i++) {
(function(token) {
if (token.type !== 'code') {
@@ -1146,6 +1160,6 @@
this.marked = marked;
}
}).call(function() {
return this || (typeof window !== 'undefined' ? window : global);
-}());
\ No newline at end of file
+}());