|
--- origin.js 2015-04-30 07:56:33.102179400 +0900 |
|
+++ fixed.js 2015-04-30 07:58:05.251312400 +0900 |
|
@@ -154,6 +154,7 @@ |
|
var block = { |
|
newline: /^\n+/, |
|
code: /^( {4}[^\n]+\n*)+/, |
|
+ mathjax: /^ *(\${2}) *([\s\S]+?)\s*\1 *(?:\n+|$)/, |
|
fences: noop, |
|
hr: /^( *[-*_]){3,} *(?:\n+|$)/, |
|
heading: /^ *(#{1,6}) *([^\n]+?) *#* *(?:\n+|$)/, |
|
@@ -186,7 +187,12 @@ |
|
type: "code", |
|
text: this.options.pedantic ? t : t.replace(/\n+$/, "") |
|
}); |
|
- else if (t = this.rules.fences.exec(e)) e = e.substring(t[0].length), this.tokens.push({ |
|
+ else if (t = this.rules.mathjax.exec(e)) e = e.substring(t[0].length), this.tokens.push({ |
|
+ type: "html", |
|
+ pre: true, |
|
+ text: t[0] |
|
+ }); |
|
+ else if (t = this.rules.fences.exec(e)) e = e.substring(t[0].length), this.tokens.push({ |
|
type: "code", |
|
lang: t[2], |
|
text: t[3] |
|
@@ -270,9 +276,10 @@ |
|
strong: /^__([\s\S]+?)__(?!_)|^\*\*([\s\S]+?)\*\*(?!\*)/, |
|
em: /^\b_((?:__|[\s\S])+?)_\b|^\*((?:\*\*|[\s\S])+?)\*(?!\*)/, |
|
code: /^(`+)\s*([\s\S]*?[^`])\s*\1(?!`)/, |
|
+ mathjax: /^(\${1,2})\s*([\s\S]*?[^\$])\s*\1(?!\$)/, |
|
br: /^ {2,}\n(?!\s*$)/, |
|
del: noop, |
|
- text: /^[\s\S]+?(?=[\\<!\[_*`]| {2,}\n|$)/ |
|
+ text: /^[\s\S]+?(?=[\\<!\[_*`\$]| {2,}\n|$)/ |
|
}; |
|
inline._inside = /(?:\[[^\]]*\]|[^\[\]]|\](?=[^\[]*\]))*/, inline._href = /\s*<?([\s\S]*?)>?(?:\s+['"]([\s\S]*?)['"])?\s*/, inline.link = replace(inline.link)("inside", inline._inside)("href", inline._href)(), inline.reflink = replace(inline.reflink)("inside", inline._inside)(), inline.normal = merge({}, inline), inline.pedantic = merge({}, inline.normal, { |
|
strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/, |
|
@@ -307,6 +314,7 @@ |
|
} else if (o = this.rules.strong.exec(e)) e = e.substring(o[0].length), t += this.renderer.strong(this.output(o[2] || o[1])); |
|
else if (o = this.rules.em.exec(e)) e = e.substring(o[0].length), t += this.renderer.em(this.output(o[2] || o[1])); |
|
else if (o = this.rules.code.exec(e)) e = e.substring(o[0].length), t += this.renderer.codespan(escape(o[2], !0)); |
|
+ else if (o = this.rules.mathjax.exec(e)) e = e.substring(o[0].length), t += o[0]; |
|
else if (o = this.rules.br.exec(e)) e = e.substring(o[0].length), t += this.renderer.br(); |
|
else if (o = this.rules.del.exec(e)) e = e.substring(o[0].length), t += this.renderer.del(this.output(o[1])); |
|
else if (o = this.rules.text.exec(e)) e = e.substring(o[0].length), t += escape(this.smartypants(o[0])); |
|
@@ -531,7 +539,7 @@ |
|
}, function(a, l) { |
|
var c = ["<!DOCTYPE html>", "<html>", "<head>", '<base href="' + o + '" />', '<meta http-equiv="Content-type" content="text/html;charset=UTF-8">', 0 !== i.length || n.isMacintosh ? "" : t.theme === h.LIGHT ? r.LIGHT_SCROLLBAR_CSS : r.DARK_SCROLLBAR_CSS, 0 === i.length ? r.DEFAULT_CSS : "", i.map(function(r) { |
|
return '<link rel="stylesheet" href="' + t.fixHref(e, r, o) + '" type="text/css" media="screen">' |
|
- }).join("\n"), '<style type="text/css">' + r.LANGUAGE_TOKENS_CSS + "</style>", "</head>", "<body>"].join("\n"), |
|
+ }).join("\n"), '<style type="text/css">' + r.LANGUAGE_TOKENS_CSS + "</style>", '<script type="text/x-mathjax-config">', "MathJax.Hub.Config({", "showProcessingMessages:false,", "tex2jax:{inlineMath:[['$','$'],['\\\\(','\\\\)']]},", "TeX:{equationNumbers:{autoNumber:'AMS'}}", "});", "document.addEventListener('DOMSubtreeModified',function(){MathJax.Hub.Queue(['Typeset',MathJax.Hub]);},false);", "</script>", '<script src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS_HTML"></script>', "</head>", "<body>"].join("\n"), |
|
d = [t.theme === h.LIGHT ? '<div class="vs">' : '<div class="vs-dark">', l, "</div>"].join("\n"), |
|
u = ["</body>", "</html>"].join("\n"); |
|
s({ |