Commit d2c8588e authored by Vanessa's avatar Vanessa

fixed #12360

parent 8e8565d0
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.0, May 21, 2017 * @version 1.2.0.0, Nov 10, 2017
*/ */
/** /**
...@@ -26,6 +26,87 @@ ...@@ -26,6 +26,87 @@
* @static * @static
*/ */
var Util = { var Util = {
/**
* 按需加载 MathJax 及 flow
* @returns {undefined}
*/
parseMarkdown: function () {
var hasMathJax = false;
var hasFlow = false;
$('.content-reset').each(function () {
$(this).find('p').each(function () {
if ($(this).text().indexOf('$/') > -1 || $(this).text().indexOf('$$') > -1) {
hasMathJax = true;
return false;
}
});
if ($(this).find('code.lang-flow, code.language-flow').length > 0) {
hasFlow = true
}
});
if (hasMathJax) {
var initMathJax = function () {
MathJax.Hub.Config({
tex2jax: {
inlineMath: [['$', '$'], ["\\(", "\\)"]],
displayMath: [['$$', '$$']],
processEscapes: true,
processEnvironments: true,
skipTags: ['pre', 'code']
}
});
MathJax.Hub.Queue(function () {
var all = MathJax.Hub.getAllJax(), i;
for (i = 0; i < all.length; i += 1) {
if ($(all[i].SourceElement().parentNode).closest('.content-reset') === 1) {
all[i].SourceElement().parentNode.className += 'has-jax';
}
}
});
};
if (typeof MathJax !== 'undefined') {
initMathJax();
return;
}
$.ajax({
method: "GET",
url: "https://cdn.staticfile.org/MathJax/MathJax-2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&_=1473258780393",
dataType: "script"
}).done(function () {
initMathJax();
});
}
if (hasFlow) {
var initFlow = function () {
$('.content-reset code.lang-flow, .content-reset code.language-flow').each(function (index) {
var $it = $(this);
var id = 'symFlow' + (new Date()).getTime() + index;
$it.hide();
var diagram = flowchart.parse($.trim($it.text()));
$it.parent().after('<div style="text-align: center" id="' + id + '"></div>')
diagram.drawSVG(id);
$it.parent().remove();
$('#' + id).find('svg').height('auto').width('auto');
});
};
if (typeof (flowchart) !== 'undefined') {
initFlow();
return;
}
$.ajax({
method: "GET",
url: latkeConfig.staticServePath + '/js/lib/flowchart/flowchart.min.js',
dataType: "script"
}).done(function () {
initFlow()
});
}
},
/** /**
* @description 是否登录 * @description 是否登录
* @returns {Boolean} 是否登录 * @returns {Boolean} 是否登录
...@@ -51,7 +132,7 @@ var Util = { ...@@ -51,7 +132,7 @@ var Util = {
/** /**
* @description 检测页面错误 * @description 检测页面错误
*/ */
error: function() { error: function () {
$("#tipMsg").text("Error: " + arguments[0] + $("#tipMsg").text("Error: " + arguments[0] +
" File: " + arguments[1] + "\nLine: " + arguments[2] + " File: " + arguments[1] + "\nLine: " + arguments[2] +
" please report this issue on https://github.com/b3log/solo/issues/new"); " please report this issue on https://github.com/b3log/solo/issues/new");
...@@ -60,8 +141,8 @@ var Util = { ...@@ -60,8 +141,8 @@ var Util = {
/** /**
* @description IE6/7,跳转到 kill-browser 页面 * @description IE6/7,跳转到 kill-browser 页面
*/ */
killIE: function() { killIE: function () {
var addKillPanel = function() { var addKillPanel = function () {
if (Cookie.readCookie("showKill") === "") { if (Cookie.readCookie("showKill") === "") {
var left = ($(window).width() - 701) / 2, var left = ($(window).width() - 701) / 2,
top1 = ($(window).height() - 420) / 2; top1 = ($(window).height() - 420) / 2;
...@@ -93,7 +174,7 @@ var Util = { ...@@ -93,7 +174,7 @@ var Util = {
* @param {String} str 替换字符串 * @param {String} str 替换字符串
* @returns {String} 替换后的字符 * @returns {String} 替换后的字符
*/ */
replaceEmString: function(str) { replaceEmString: function (str) {
var commentSplited = str.split("[em"); var commentSplited = str.split("[em");
if (commentSplited.length === 1) { if (commentSplited.length === 1) {
return str; return str;
...@@ -113,7 +194,7 @@ var Util = { ...@@ -113,7 +194,7 @@ var Util = {
* @param {String} url URL 地址 * @param {String} url URL 地址
* @returns {String} 添加后的URL * @returns {String} 添加后的URL
*/ */
proessURL: function(url) { proessURL: function (url) {
if (!/^\w+:\/\//.test(url)) { if (!/^\w+:\/\//.test(url)) {
url = "http://" + url; url = "http://" + url;
} }
...@@ -123,24 +204,24 @@ var Util = { ...@@ -123,24 +204,24 @@ var Util = {
* @description 切换到手机版 * @description 切换到手机版
* @param {String} skin 切换前的皮肤名称 * @param {String} skin 切换前的皮肤名称
*/ */
switchMobile: function(skin) { switchMobile: function (skin) {
Cookie.createCookie("btouch_switch_toggle", skin, 365); Cookie.createCookie("btouch_switch_toggle", skin, 365);
setTimeout(function() { setTimeout(function () {
location.reload(); location.reload();
}, 1250); }, 1250);
}, },
/** /**
* @description topbar 相关事件 * @description topbar 相关事件
*/ */
setTopBar: function() { setTopBar: function () {
var $top = $("#top"); var $top = $("#top");
if ($top.length === 1) { if ($top.length === 1) {
var $showTop = $("#showTop"); var $showTop = $("#showTop");
$showTop.click(function() { $showTop.click(function () {
$top.slideDown(); $top.slideDown();
$showTop.hide(); $showTop.hide();
}); });
$("#hideTop").click(function() { $("#hideTop").click(function () {
$top.slideUp(); $top.slideUp();
$showTop.show(); $showTop.show();
}); });
...@@ -149,13 +230,13 @@ var Util = { ...@@ -149,13 +230,13 @@ var Util = {
/** /**
* @description 回到顶部 * @description 回到顶部
*/ */
goTop: function() { goTop: function () {
$('html, body').animate({scrollTop : 0},800); $('html, body').animate({scrollTop: 0}, 800);
}, },
/** /**
* @description 回到底部 * @description 回到底部
*/ */
goBottom: function(bottom) { goBottom: function (bottom) {
if (!bottom) { if (!bottom) {
bottom = 0; bottom = 0;
} }
...@@ -165,7 +246,7 @@ var Util = { ...@@ -165,7 +246,7 @@ var Util = {
/** /**
* @description 页面初始化执行的函数 * @description 页面初始化执行的函数
*/ */
init: function() { init: function () {
//window.onerror = Util.error; //window.onerror = Util.error;
Util.killIE(); Util.killIE();
Util.setTopBar(); Util.setTopBar();
...@@ -174,7 +255,7 @@ var Util = { ...@@ -174,7 +255,7 @@ var Util = {
* @description 替换侧边栏表情为图片 * @description 替换侧边栏表情为图片
* @param {Dom} comments 评论内容元素 * @param {Dom} comments 评论内容元素
*/ */
replaceSideEm: function(comments) { replaceSideEm: function (comments) {
for (var i = 0; i < comments.length; i++) { for (var i = 0; i < comments.length; i++) {
var $comment = $(comments[i]); var $comment = $(comments[i]);
$comment.html(Util.replaceEmString($comment.html())); $comment.html(Util.replaceEmString($comment.html()));
...@@ -184,7 +265,7 @@ var Util = { ...@@ -184,7 +265,7 @@ var Util = {
* @description 根据 tags,穿件云效果 * @description 根据 tags,穿件云效果
* @param {String} [id] tags 根元素 id,默认为 tags * @param {String} [id] tags 根元素 id,默认为 tags
*/ */
buildTags: function(id) { buildTags: function (id) {
id = id || "tags"; id = id || "tags";
// 根据引用次数添加样式,产生云效果 // 根据引用次数添加样式,产生云效果
var classes = ["tags1", "tags2", "tags3", "tags4", "tags5"], var classes = ["tags1", "tags2", "tags3", "tags4", "tags5"],
...@@ -203,7 +284,7 @@ var Util = { ...@@ -203,7 +284,7 @@ var Util = {
} }
// 按字母或者中文拼音进行排序 // 按字母或者中文拼音进行排序
$("#" + id).html($("#" + id + " li").get().sort(function(a, b) { $("#" + id).html($("#" + id + " li").get().sort(function (a, b) {
var valA = $(a).find("span").text().toLowerCase(); var valA = $(a).find("span").text().toLowerCase();
var valB = $(b).find("span").text().toLowerCase(); var valB = $(b).find("span").text().toLowerCase();
// 对中英文排序的处理 // 对中英文排序的处理
...@@ -216,7 +297,7 @@ var Util = { ...@@ -216,7 +297,7 @@ var Util = {
* @param {String} format 格式化后日期格式 * @param {String} format 格式化后日期格式
* @returns {String} 格式化后的时间 * @returns {String} 格式化后的时间
*/ */
toDate: function(time, format) { toDate: function (time, format) {
var dateTime = new Date(time); var dateTime = new Date(time);
var o = { var o = {
"M+": dateTime.getMonth() + 1, //month "M+": dateTime.getMonth() + 1, //month
...@@ -243,7 +324,7 @@ var Util = { ...@@ -243,7 +324,7 @@ var Util = {
* @description 获取窗口高度 * @description 获取窗口高度
* @returns {Inter} 窗口高度 * @returns {Inter} 窗口高度
*/ */
getWinHeight: function() { getWinHeight: function () {
if (window.innerHeight) { if (window.innerHeight) {
return window.innerHeight; return window.innerHeight;
} }
...@@ -264,7 +345,7 @@ if (!Cookie) { ...@@ -264,7 +345,7 @@ if (!Cookie) {
* @param {String} name cookie key * @param {String} name cookie key
* @returns {String} 对应 key 的值,如 key 不存在则返回 "" * @returns {String} 对应 key 的值,如 key 不存在则返回 ""
*/ */
readCookie: function(name) { readCookie: function (name) {
var nameEQ = name + "="; var nameEQ = name + "=";
var ca = document.cookie.split(';'); var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) { for (var i = 0; i < ca.length; i++) {
...@@ -280,7 +361,7 @@ if (!Cookie) { ...@@ -280,7 +361,7 @@ if (!Cookie) {
* @description 清除 Cookie * @description 清除 Cookie
* @param {String} name 清除 key 为 name 的该条 Cookie * @param {String} name 清除 key 为 name 的该条 Cookie
*/ */
eraseCookie: function(name) { eraseCookie: function (name) {
this.createCookie(name, "", -1); this.createCookie(name, "", -1);
}, },
/** /**
...@@ -289,7 +370,7 @@ if (!Cookie) { ...@@ -289,7 +370,7 @@ if (!Cookie) {
* @param {String} value 每条 Cookie 对应的值,将被 UTF-8 编码 * @param {String} value 每条 Cookie 对应的值,将被 UTF-8 编码
* @param {Int} days Cookie 保存时间 * @param {Int} days Cookie 保存时间
*/ */
createCookie: function(name, value, days) { createCookie: function (name, value, days) {
var expires = ""; var expires = "";
if (days) { if (days) {
var date = new Date(); var date = new Date();
......
.CodeMirror{font-family:monospace;height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror-lines pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta,.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-invalidchar,.cm-s-default .cm-error{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important;-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror-lines pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}.CodeMirror-focused div.CodeMirror-cursors,div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}.CodeMirror-hints{position:absolute;z-index:100;overflow:hidden;list-style:none;margin:0;padding:2px;-webkit-box-shadow:2px 3px 5px rgba(0,0,0,.2);-moz-box-shadow:2px 3px 5px rgba(0,0,0,.2);box-shadow:2px 3px 5px rgba(0,0,0,.2);border-radius:3px;border:1px solid silver;background:#fff;font-size:90%;font-family:monospace;max-height:20em;overflow-y:auto}.CodeMirror-preview,.editor-toolbar{box-shadow:0 1px 2px rgba(0,0,0,.075) inset}.CodeMirror-hint{margin:0;padding:0 4px;border-radius:2px;max-width:19em;overflow:hidden;white-space:pre;color:#000;cursor:pointer}li.CodeMirror-hint-active{background:#08f;color:#fff}.CodeMirror-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;height:auto;z-index:9}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.CodeMirror-merge-2pane .CodeMirror-merge-pane{width:49%;border:1px solid #CCC;border-radius:3px}.CodeMirror-merge-2pane .CodeMirror-merge-gap{width:0;display:none}.CodeMirror-merge-3pane .CodeMirror-merge-pane{width:31%}.CodeMirror-merge-3pane .CodeMirror-merge-gap{width:3.5%}.CodeMirror-merge-pane{display:inline-block;white-space:normal;vertical-align:top}.CodeMirror-merge-pane-rightmost{float:right}.CodeMirror-merge-gap{z-index:2;display:inline-block;height:100%;-moz-box-sizing:border-box;box-sizing:border-box;overflow:hidden;border-left:1px solid #ddd;border-right:1px solid #ddd;position:relative;background:#f8f8f8}.CodeMirror-merge-scrolllock-wrap{position:absolute;bottom:0;left:50%}.CodeMirror-merge-scrolllock{position:relative;left:-50%;cursor:pointer;color:#555;line-height:1;display:none}.CodeMirror-merge-copy,.CodeMirror-merge-copy-reverse{position:absolute;color:#44c;cursor:pointer}.CodeMirror-merge-copybuttons-left,.CodeMirror-merge-copybuttons-right{position:absolute;left:0;top:0;right:0;bottom:0;line-height:1}.CodeMirror-merge-copy{z-index:3}.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy{left:2px}.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy{right:2px}.CodeMirror-merge-l-inserted,.CodeMirror-merge-r-inserted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-l-deleted,.CodeMirror-merge-r-deleted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-r-chunk{background:#ffffe0}.CodeMirror-merge-r-chunk-start{border-top:1px solid #ee8}.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #ee8}.CodeMirror-merge-r-connect{fill:#ffffe0;stroke:#ee8;stroke-width:1px}.CodeMirror-merge-l-chunk{background:#eef}.CodeMirror-merge-l-chunk-start{border-top:1px solid #88e}.CodeMirror-merge-l-chunk-end{border-bottom:1px solid #88e}.CodeMirror-merge-l-connect{fill:#eef;stroke:#88e;stroke-width:1px}.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk{background:#dfd}.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start{border-top:1px solid #4e4}.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #4e4}.CodeMirror-merge-collapsed-widget:before{content:"(...)"}.CodeMirror-merge-collapsed-widget{cursor:pointer;color:#88b;background:#eef;border:1px solid #ddf;font-size:90%;padding:0 3px;border-radius:4px}.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt{display:none}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}:-webkit-full-screen{background:#f9f9f5;padding:.5em 1em;width:100%;height:100%}:-moz-full-screen{padding:.5em 1em;background:#f9f9f5;width:100%;height:100%}.editor-wrapper{font:16px/1.62 "Helvetica Neue","Xin Gothic","Hiragino Sans GB","WenQuanYi Micro Hei","Microsoft YaHei",sans-serif;color:#2c3e50}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;border:1px solid #CCC;background-color:#FAFAFA;border-bottom-width:0;border-radius:3px 3px 0 0;height:34px}.editor-toolbar a,.editor-toolbar label{text-decoration:none!important;font-size:16px;color:#666;padding:5px 10px;cursor:pointer;line-height:24px;display:inline-block;top:-1px}.editor-toolbar a.active,.editor-toolbar a.focus,.editor-toolbar a:hover,.editor-toolbar label.active,.editor-toolbar label:hover{background:#666;color:#fff}.editor-toolbar a:before,.editor-toolbar label:before{line-height:24px}.editor-toolbar label.icon-upload{margin:0;position:relative}.editor-toolbar input{height:1px;position:absolute;left:0;top:0;opacity:.001}.editor-toolbar form{overflow:hidden;display:initial}.CodeMirror-preview,.editor-preview{position:absolute;box-sizing:border-box;overflow:auto}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 5px}.editor-toolbar a.icon-contract,.editor-toolbar a.icon-fullscreen{position:absolute;right:0}.editor-statusbar{border-top:1px solid #ece9e9;padding:8px 10px;font-size:12px;color:#959694;text-align:right}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-preview{width:100%;height:100%;top:1px;padding:0 4px;left:100%;background:#FDFDFD;z-index:10;-webkit-transition:left .2s ease;-moz-transition:left .2s ease;-ms-transition:left .2s ease;transition:left .2s ease}.editor-preview-active{left:0}.editor-preview>p{margin-top:0}.CodeMirror-preview{background-color:#FFF;width:50%;top:30px;border-left:1px solid #ccc;border-radius:0 0 3px;border-top:0;right:0;padding:4px} .CodeMirror{font-family:monospace;height:300px;color:#000}.CodeMirror-lines{padding:4px 0}.CodeMirror-lines pre{padding:0 4px}.CodeMirror-gutter-filler,.CodeMirror-scrollbar-filler{background-color:#fff}.CodeMirror-gutters{border-right:1px solid #ddd;background-color:#f7f7f7;white-space:nowrap}.CodeMirror-linenumber{padding:0 3px 0 5px;min-width:20px;text-align:right;color:#999;white-space:nowrap}.CodeMirror-guttermarker{color:#000}.CodeMirror-guttermarker-subtle{color:#999}.CodeMirror-cursor{border-left:1px solid #000;border-right:none;width:0}.CodeMirror div.CodeMirror-secondarycursor{border-left:1px solid silver}.cm-fat-cursor .CodeMirror-cursor{width:auto;border:0;background:#7e7}.cm-fat-cursor div.CodeMirror-cursors{z-index:1}.cm-animate-fat-cursor{width:auto;border:0;-webkit-animation:blink 1.06s steps(1) infinite;-moz-animation:blink 1.06s steps(1) infinite;animation:blink 1.06s steps(1) infinite;background-color:#7e7}@-moz-keyframes blink{50%{background-color:transparent}}@-webkit-keyframes blink{50%{background-color:transparent}}@keyframes blink{50%{background-color:transparent}}.cm-tab{display:inline-block;text-decoration:inherit}.CodeMirror-ruler{border-left:1px solid #ccc;position:absolute}.cm-s-default .cm-header{color:#00f}.cm-s-default .cm-quote{color:#090}.cm-negative{color:#d44}.cm-positive{color:#292}.cm-header,.cm-strong{font-weight:700}.cm-em{font-style:italic}.cm-link{text-decoration:underline}.cm-strikethrough{text-decoration:line-through}.cm-s-default .cm-keyword{color:#708}.cm-s-default .cm-atom{color:#219}.cm-s-default .cm-number{color:#164}.cm-s-default .cm-def{color:#00f}.cm-s-default .cm-variable-2{color:#05a}.cm-s-default .cm-variable-3{color:#085}.cm-s-default .cm-comment{color:#a50}.cm-s-default .cm-string{color:#a11}.cm-s-default .cm-string-2{color:#f50}.cm-s-default .cm-meta{color:#555}.cm-s-default .cm-qualifier{color:#555}.cm-s-default .cm-builtin{color:#30a}.cm-s-default .cm-bracket{color:#997}.cm-s-default .cm-tag{color:#170}.cm-s-default .cm-attribute{color:#00c}.cm-s-default .cm-hr{color:#999}.cm-s-default .cm-link{color:#00c}.cm-s-default .cm-error{color:red}.cm-invalidchar{color:red}.CodeMirror-composing{border-bottom:2px solid}div.CodeMirror span.CodeMirror-matchingbracket{color:#0f0}div.CodeMirror span.CodeMirror-nonmatchingbracket{color:#f22}.CodeMirror-matchingtag{background:rgba(255,150,0,.3)}.CodeMirror-activeline-background{background:#e8f2ff}.CodeMirror{position:relative;overflow:hidden;background:#fff}.CodeMirror-scroll{overflow:scroll!important;margin-bottom:-30px;margin-right:-30px;padding-bottom:30px;height:100%;outline:0;position:relative}.CodeMirror-sizer{position:relative;border-right:30px solid transparent}.CodeMirror-gutter-filler,.CodeMirror-hscrollbar,.CodeMirror-scrollbar-filler,.CodeMirror-vscrollbar{position:absolute;z-index:6;display:none}.CodeMirror-vscrollbar{right:0;top:0;overflow-x:hidden;overflow-y:scroll}.CodeMirror-hscrollbar{bottom:0;left:0;overflow-y:hidden;overflow-x:scroll}.CodeMirror-scrollbar-filler{right:0;bottom:0}.CodeMirror-gutter-filler{left:0;bottom:0}.CodeMirror-gutters{position:absolute;left:0;top:0;z-index:3}.CodeMirror-gutter{white-space:normal;height:100%;display:inline-block;margin-bottom:-30px}.CodeMirror-gutter-wrapper{position:absolute;z-index:4;background:0 0!important;border:none!important}.CodeMirror-gutter-background{position:absolute;top:0;bottom:0;z-index:4}.CodeMirror-gutter-elt{position:absolute;cursor:default;z-index:4}.CodeMirror-gutter-wrapper{-webkit-user-select:none;-moz-user-select:none;user-select:none}.CodeMirror-lines{cursor:text;min-height:1px}.CodeMirror-lines pre{-moz-border-radius:0;-webkit-border-radius:0;border-radius:0;border-width:0;background:0 0;font-family:inherit;font-size:inherit;margin:0;white-space:pre;word-wrap:normal;line-height:inherit;color:inherit;z-index:2;position:relative;overflow:visible;-webkit-tap-highlight-color:transparent}.CodeMirror-wrap pre{word-wrap:break-word;white-space:pre-wrap;word-break:normal}.CodeMirror-linebackground{position:absolute;left:0;right:0;top:0;bottom:0;z-index:0}.CodeMirror-linewidget{position:relative;z-index:2;overflow:auto}.CodeMirror-code{outline:0}.CodeMirror-gutter,.CodeMirror-gutters,.CodeMirror-linenumber,.CodeMirror-scroll,.CodeMirror-sizer{-moz-box-sizing:content-box;box-sizing:content-box}.CodeMirror-measure{position:absolute;width:100%;height:0;overflow:hidden;visibility:hidden}.CodeMirror-cursor{position:absolute}.CodeMirror-measure pre{position:static}div.CodeMirror-cursors{visibility:hidden;position:relative;z-index:3}div.CodeMirror-dragcursors{visibility:visible}.CodeMirror-focused div.CodeMirror-cursors{visibility:visible}.CodeMirror-selected{background:#d9d9d9}.CodeMirror-focused .CodeMirror-selected{background:#d7d4f0}.CodeMirror-crosshair{cursor:crosshair}.CodeMirror-line::selection,.CodeMirror-line>span::selection,.CodeMirror-line>span>span::selection{background:#d7d4f0}.CodeMirror-line::-moz-selection,.CodeMirror-line>span::-moz-selection,.CodeMirror-line>span>span::-moz-selection{background:#d7d4f0}.cm-searching{background:#ffa;background:rgba(255,255,0,.4)}.cm-force-border{padding-right:.1px}.CodeMirror-hints{position:absolute;z-index:100;overflow:hidden;list-style:none;margin:0;padding:2px;-webkit-box-shadow:2px 3px 5px rgba(0,0,0,.2);-moz-box-shadow:2px 3px 5px rgba(0,0,0,.2);box-shadow:2px 3px 5px rgba(0,0,0,.2);border-radius:3px;border:1px solid silver;background:#fff;font-size:90%;font-family:monospace;max-height:20em;overflow-y:auto}.CodeMirror-hint{margin:0;padding:0 4px;border-radius:2px;max-width:19em;overflow:hidden;white-space:pre;color:#000;cursor:pointer}li.CodeMirror-hint-active{background:#08f;color:#fff}.CodeMirror-fullscreen{position:fixed;top:0;left:0;right:0;bottom:0;height:auto;z-index:9}@media print{.CodeMirror div.CodeMirror-cursors{visibility:hidden}}.CodeMirror-merge-2pane .CodeMirror-merge-pane{width:49%;border:1px solid #ccc;border-radius:3px}.CodeMirror-merge-2pane .CodeMirror-merge-gap{width:0;display:none}.CodeMirror-merge-3pane .CodeMirror-merge-pane{width:31%}.CodeMirror-merge-3pane .CodeMirror-merge-gap{width:3.5%}.CodeMirror-merge-pane{display:inline-block;white-space:normal;vertical-align:top}.CodeMirror-merge-pane-rightmost{float:right}.CodeMirror-merge-gap{z-index:2;display:inline-block;height:100%;-moz-box-sizing:border-box;box-sizing:border-box;overflow:hidden;border-left:1px solid #ddd;border-right:1px solid #ddd;position:relative;background:#f8f8f8}.CodeMirror-merge-scrolllock-wrap{position:absolute;bottom:0;left:50%}.CodeMirror-merge-scrolllock{position:relative;left:-50%;cursor:pointer;color:#555;line-height:1;display:none}.CodeMirror-merge-copybuttons-left,.CodeMirror-merge-copybuttons-right{position:absolute;left:0;top:0;right:0;bottom:0;line-height:1}.CodeMirror-merge-copy{position:absolute;cursor:pointer;color:#44c;z-index:3}.CodeMirror-merge-copy-reverse{position:absolute;cursor:pointer;color:#44c}.CodeMirror-merge-copybuttons-left .CodeMirror-merge-copy{left:2px}.CodeMirror-merge-copybuttons-right .CodeMirror-merge-copy{right:2px}.CodeMirror-merge-l-inserted,.CodeMirror-merge-r-inserted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12MwuCXy3+CWyH8GBgYGJgYkAABZbAQ9ELXurwAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-l-deleted,.CodeMirror-merge-r-deleted{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAMAAAACCAYAAACddGYaAAAAGUlEQVQI12M4Kyb2/6yY2H8GBgYGJgYkAABURgPz6Ks7wQAAAABJRU5ErkJggg==);background-position:bottom left;background-repeat:repeat-x}.CodeMirror-merge-r-chunk{background:#ffffe0}.CodeMirror-merge-r-chunk-start{border-top:1px solid #ee8}.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #ee8}.CodeMirror-merge-r-connect{fill:#ffffe0;stroke:#ee8;stroke-width:1px}.CodeMirror-merge-l-chunk{background:#eef}.CodeMirror-merge-l-chunk-start{border-top:1px solid #88e}.CodeMirror-merge-l-chunk-end{border-bottom:1px solid #88e}.CodeMirror-merge-l-connect{fill:#eef;stroke:#88e;stroke-width:1px}.CodeMirror-merge-l-chunk.CodeMirror-merge-r-chunk{background:#dfd}.CodeMirror-merge-l-chunk-start.CodeMirror-merge-r-chunk-start{border-top:1px solid #4e4}.CodeMirror-merge-l-chunk-end.CodeMirror-merge-r-chunk-end{border-bottom:1px solid #4e4}.CodeMirror-merge-collapsed-widget:before{content:"(...)"}.CodeMirror-merge-collapsed-widget{cursor:pointer;color:#88b;background:#eef;border:1px solid #ddf;font-size:90%;padding:0 3px;border-radius:4px}.CodeMirror-merge-collapsed-line .CodeMirror-gutter-elt{display:none}.cm-tab-wrap-hack:after{content:''}span.CodeMirror-selectedtext{background:0 0}:-webkit-full-screen{background:#f9f9f5;padding:.5em 1em;width:100%;height:100%}:-moz-full-screen{padding:.5em 1em;background:#f9f9f5;width:100%;height:100%}.editor-wrapper{font:16px/1.62 "Helvetica Neue","Xin Gothic","Hiragino Sans GB","WenQuanYi Micro Hei","Microsoft YaHei",sans-serif;color:#2c3e50}.editor-toolbar{position:relative;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;border:1px solid #ccc;background-color:#fafafa;box-shadow:0 1px 2px rgba(0,0,0,.075) inset;border-bottom-width:0;border-radius:3px 3px 0 0;height:34px}.editor-toolbar a,.editor-toolbar label{text-decoration:none!important;font-size:16px;color:#666;padding:5px 10px;cursor:pointer;line-height:24px;display:inline-block;top:-1px}.editor-toolbar a.active,.editor-toolbar a.focus,.editor-toolbar a:hover,.editor-toolbar label.active,.editor-toolbar label:hover{background:#666;color:#fff}.editor-toolbar a:before,.editor-toolbar label:before{line-height:24px}.editor-toolbar label.icon-upload{margin:0;position:relative}.editor-toolbar input{height:1px;position:absolute;left:0;top:0;opacity:.001}.editor-toolbar form{overflow:hidden;display:initial}.editor-toolbar i.separator{display:inline-block;width:0;border-left:1px solid #d9d9d9;border-right:1px solid #fff;color:transparent;text-indent:-10px;margin:0 5px}.editor-toolbar a.icon-contract,.editor-toolbar a.icon-fullscreen{position:absolute;right:0}.editor-statusbar{border-top:1px solid #ece9e9;padding:8px 10px;font-size:12px;color:#959694;text-align:right}.editor-statusbar span{display:inline-block;min-width:4em;margin-left:1em}.editor-statusbar .lines:before{content:'lines: '}.editor-statusbar .words:before{content:'words: '}.editor-preview{position:absolute;width:100%;height:100%;top:1px;padding:0 4px;left:100%;background:#fdfdfd;z-index:10;overflow:auto;-webkit-transition:left .2s ease;-moz-transition:left .2s ease;-ms-transition:left .2s ease;transition:left .2s ease;box-sizing:border-box}.editor-preview-active{left:0}.editor-preview>p{margin-top:0}.CodeMirror-preview{background-color:#fff;width:50%;top:30px;border-left:1px solid #ccc;border-radius:0 0 3px;border-top:0;overflow:hidden;right:0;position:absolute;box-shadow:0 1px 2px rgba(0,0,0,.075) inset;padding:4px;box-sizing:border-box;overflow:auto}
\ No newline at end of file \ No newline at end of file
...@@ -68,24 +68,30 @@ ...@@ -68,24 +68,30 @@
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true; var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag || true;
var Kludges = parserConfig.htmlMode ? { var Kludges = parserConfig.htmlMode ? {
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true, autoSelfClosers: {
'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true, 'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true, 'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
'track': true, 'wbr': true}, 'track': true, 'wbr': true
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true, },
implicitlyClosed: {
'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true, 'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
'th': true, 'tr': true}, 'th': true, 'tr': true
},
contextGrabbers: { contextGrabbers: {
'dd': {'dd': true, 'dt': true}, 'dd': {'dd': true, 'dt': true},
'dt': {'dd': true, 'dt': true}, 'dt': {'dd': true, 'dt': true},
'li': {'li': true}, 'li': {'li': true},
'option': {'option': true, 'optgroup': true}, 'option': {'option': true, 'optgroup': true},
'optgroup': {'optgroup': true}, 'optgroup': {'optgroup': true},
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true, 'p': {
'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true, 'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true, 'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true, 'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true}, 'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true
},
'rp': {'rp': true, 'rt': true}, 'rp': {'rp': true, 'rt': true},
'rt': {'rp': true, 'rt': true}, 'rt': {'rp': true, 'rt': true},
'tbody': {'tbody': true, 'tfoot': true}, 'tbody': {'tbody': true, 'tfoot': true},
...@@ -111,8 +117,8 @@ ...@@ -111,8 +117,8 @@
// Return variables for tokenizers // Return variables for tokenizers
var tagName, type; var tagName, type;
function inText(stream, state) { function inText (stream, state) {
function chain(parser) { function chain (parser) {
state.tokenize = parser; state.tokenize = parser;
return parser(stream, state); return parser(stream, state);
} }
...@@ -167,7 +173,7 @@ ...@@ -167,7 +173,7 @@
} }
} }
function inTag(stream, state) { function inTag (stream, state) {
var ch = stream.next(); var ch = stream.next();
if (ch == ">" || (ch == "/" && stream.eat(">"))) { if (ch == ">" || (ch == "/" && stream.eat(">"))) {
state.tokenize = inText; state.tokenize = inText;
...@@ -188,7 +194,7 @@ ...@@ -188,7 +194,7 @@
} }
} }
function inAttribute(quote) { function inAttribute (quote) {
var closure = function (stream, state) { var closure = function (stream, state) {
while (!stream.eol()) { while (!stream.eol()) {
if (stream.next() == quote) { if (stream.next() == quote) {
...@@ -202,7 +208,7 @@ ...@@ -202,7 +208,7 @@
return closure; return closure;
} }
function inBlock(style, terminator) { function inBlock (style, terminator) {
return function (stream, state) { return function (stream, state) {
while (!stream.eol()) { while (!stream.eol()) {
if (stream.match(terminator)) { if (stream.match(terminator)) {
...@@ -214,7 +220,8 @@ ...@@ -214,7 +220,8 @@
return style; return style;
}; };
} }
function doctype(depth) {
function doctype (depth) {
return function (stream, state) { return function (stream, state) {
var ch; var ch;
while ((ch = stream.next()) != null) { while ((ch = stream.next()) != null) {
...@@ -236,16 +243,18 @@ ...@@ -236,16 +243,18 @@
} }
var curState, curStream, setStyle; var curState, curStream, setStyle;
function pass() {
function pass () {
for (var i = arguments.length - 1; i >= 0; i--) for (var i = arguments.length - 1; i >= 0; i--)
curState.cc.push(arguments[i]); curState.cc.push(arguments[i]);
} }
function cont() {
function cont () {
pass.apply(null, arguments); pass.apply(null, arguments);
return true; return true;
} }
function pushContext(tagName, startOfLine) { function pushContext (tagName, startOfLine) {
var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent); var noIndent = Kludges.doNotIndent.hasOwnProperty(tagName) || (curState.context && curState.context.noIndent);
curState.context = { curState.context = {
prev: curState.context, prev: curState.context,
...@@ -255,12 +264,13 @@ ...@@ -255,12 +264,13 @@
noIndent: noIndent noIndent: noIndent
}; };
} }
function popContext() {
function popContext () {
if (curState.context) if (curState.context)
curState.context = curState.context.prev; curState.context = curState.context.prev;
} }
function element(type) { function element (type) {
if (type == "openTag") { if (type == "openTag") {
curState.tagName = tagName; curState.tagName = tagName;
curState.tagStart = curStream.column(); curState.tagStart = curStream.column();
...@@ -283,7 +293,8 @@ ...@@ -283,7 +293,8 @@
} }
return cont(); return cont();
} }
function endtag(startOfLine) {
function endtag (startOfLine) {
return function (type) { return function (type) {
var tagName = curState.tagName; var tagName = curState.tagName;
curState.tagName = curState.tagStart = null; curState.tagName = curState.tagStart = null;
...@@ -300,7 +311,8 @@ ...@@ -300,7 +311,8 @@
return cont(); return cont();
}; };
} }
function endclosetag(err) {
function endclosetag (err) {
return function (type) { return function (type) {
if (err) if (err)
setStyle = "error"; setStyle = "error";
...@@ -312,7 +324,8 @@ ...@@ -312,7 +324,8 @@
return cont(arguments.callee); return cont(arguments.callee);
}; };
} }
function maybePopContext(nextTagName) {
function maybePopContext (nextTagName) {
var parentTagName; var parentTagName;
while (true) { while (true) {
if (!curState.context) { if (!curState.context) {
...@@ -327,7 +340,7 @@ ...@@ -327,7 +340,7 @@
} }
} }
function attributes(type) { function attributes (type) {
if (type == "word") { if (type == "word") {
setStyle = "attribute"; setStyle = "attribute";
return cont(attribute, attributes); return cont(attribute, attributes);
...@@ -337,7 +350,8 @@ ...@@ -337,7 +350,8 @@
setStyle = "error"; setStyle = "error";
return cont(attributes); return cont(attributes);
} }
function attribute(type) {
function attribute (type) {
if (type == "equals") if (type == "equals")
return cont(attvalue, attributes); return cont(attvalue, attributes);
if (!Kludges.allowMissing) if (!Kludges.allowMissing)
...@@ -346,7 +360,8 @@ ...@@ -346,7 +360,8 @@
setStyle = "attribute"; setStyle = "attribute";
return (type == "endTag" || type == "selfcloseTag") ? pass() : cont(); return (type == "endTag" || type == "selfcloseTag") ? pass() : cont();
} }
function attvalue(type) {
function attvalue (type) {
if (type == "string") if (type == "string")
return cont(attvaluemaybe); return cont(attvaluemaybe);
if (type == "word" && Kludges.allowUnquoted) { if (type == "word" && Kludges.allowUnquoted) {
...@@ -356,7 +371,8 @@ ...@@ -356,7 +371,8 @@
setStyle = "error"; setStyle = "error";
return (type == "endTag" || type == "selfCloseTag") ? pass() : cont(); return (type == "endTag" || type == "selfCloseTag") ? pass() : cont();
} }
function attvaluemaybe(type) {
function attvaluemaybe (type) {
if (type == "string") if (type == "string")
return cont(attvaluemaybe); return cont(attvaluemaybe);
else else
...@@ -513,12 +529,12 @@ ...@@ -513,12 +529,12 @@
, headerRE = /^(?:\={1,}|-{1,})$/ , headerRE = /^(?:\={1,}|-{1,})$/
, textRE = /^[^!\[\]*_~\\<>` "'(]+/; , textRE = /^[^!\[\]*_~\\<>` "'(]+/;
function switchInline(stream, state, f) { function switchInline (stream, state, f) {
state.f = state.inline = f; state.f = state.inline = f;
return f(stream, state); return f(stream, state);
} }
function switchBlock(stream, state, f) { function switchBlock (stream, state, f) {
state.f = state.block = f; state.f = state.block = f;
return f(stream, state); return f(stream, state);
} }
...@@ -526,7 +542,7 @@ ...@@ -526,7 +542,7 @@
// Blocks // Blocks
function blankLine(state) { function blankLine (state) {
// Reset linkTitle state // Reset linkTitle state
state.linkTitle = false; state.linkTitle = false;
// Reset EM state // Reset EM state
...@@ -550,7 +566,7 @@ ...@@ -550,7 +566,7 @@
return null; return null;
} }
function blockNormal(stream, state) { function blockNormal (stream, state) {
var prevLineIsList = (state.list !== false); var prevLineIsList = (state.list !== false);
if (state.list !== false && state.indentationDiff >= 0) { // Continued list if (state.list !== false && state.indentationDiff >= 0) { // Continued list
...@@ -605,7 +621,7 @@ ...@@ -605,7 +621,7 @@
return switchInline(stream, state, state.inline); return switchInline(stream, state, state.inline);
} }
function htmlBlock(stream, state) { function htmlBlock (stream, state) {
var style = htmlMode.token(stream, state.htmlState); var style = htmlMode.token(stream, state.htmlState);
if (htmlFound && style === 'tag' && state.htmlState.type !== 'openTag' && !state.htmlState.context) { if (htmlFound && style === 'tag' && state.htmlState.type !== 'openTag' && !state.htmlState.context) {
state.f = inlineNormal; state.f = inlineNormal;
...@@ -619,7 +635,7 @@ ...@@ -619,7 +635,7 @@
return style; return style;
} }
function local(stream, state) { function local (stream, state) {
if (stream.sol() && stream.match(/^```/, true)) { if (stream.sol() && stream.match(/^```/, true)) {
state.localMode = state.localState = null; state.localMode = state.localState = null;
state.f = inlineNormal; state.f = inlineNormal;
...@@ -634,7 +650,7 @@ ...@@ -634,7 +650,7 @@
} }
// Inline // Inline
function getType(state) { function getType (state) {
var styles = []; var styles = [];
if (state.taskOpen) { if (state.taskOpen) {
...@@ -688,14 +704,14 @@ ...@@ -688,14 +704,14 @@
return styles.length ? styles.join(' ') : null; return styles.length ? styles.join(' ') : null;
} }
function handleText(stream, state) { function handleText (stream, state) {
if (stream.match(textRE, true)) { if (stream.match(textRE, true)) {
return getType(state); return getType(state);
} }
return undefined; return undefined;
} }
function inlineNormal(stream, state) { function inlineNormal (stream, state) {
var style = state.text(stream, state); var style = state.text(stream, state);
if (typeof style !== 'undefined') if (typeof style !== 'undefined')
return style; return style;
...@@ -858,7 +874,7 @@ ...@@ -858,7 +874,7 @@
return getType(state); return getType(state);
} }
function linkHref(stream, state) { function linkHref (stream, state) {
// Check if space, and return NULL if so (to avoid marking the space) // Check if space, and return NULL if so (to avoid marking the space)
if (stream.eatSpace()) { if (stream.eatSpace()) {
return null; return null;
...@@ -870,7 +886,7 @@ ...@@ -870,7 +886,7 @@
return 'error'; return 'error';
} }
function footnoteLink(stream, state) { function footnoteLink (stream, state) {
if (stream.match(/^[^\]]*\]:/, true)) { if (stream.match(/^[^\]]*\]:/, true)) {
state.f = footnoteUrl; state.f = footnoteUrl;
return linktext; return linktext;
...@@ -878,7 +894,7 @@ ...@@ -878,7 +894,7 @@
return switchInline(stream, state, inlineNormal); return switchInline(stream, state, inlineNormal);
} }
function footnoteUrl(stream, state) { function footnoteUrl (stream, state) {
// Check if space, and return NULL if so (to avoid marking the space) // Check if space, and return NULL if so (to avoid marking the space)
if (stream.eatSpace()) { if (stream.eatSpace()) {
return null; return null;
...@@ -896,7 +912,8 @@ ...@@ -896,7 +912,8 @@
} }
var savedInlineRE = []; var savedInlineRE = [];
function inlineRE(endChar) {
function inlineRE (endChar) {
if (!savedInlineRE[endChar]) { if (!savedInlineRE[endChar]) {
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741) // Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
endChar = (endChar + '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1"); endChar = (endChar + '').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
...@@ -907,7 +924,7 @@ ...@@ -907,7 +924,7 @@
return savedInlineRE[endChar]; return savedInlineRE[endChar];
} }
function inlineElement(type, endChar, next) { function inlineElement (type, endChar, next) {
next = next || inlineNormal; next = next || inlineNormal;
return function (stream, state) { return function (stream, state) {
stream.match(inlineRE(endChar)); stream.match(inlineRE(endChar));
...@@ -1029,7 +1046,7 @@ ...@@ -1029,7 +1046,7 @@
/** /**
* Fix shortcut. Mac use Command, others use Ctrl. * Fix shortcut. Mac use Command, others use Ctrl.
*/ */
function fixShortcut(name) { function fixShortcut (name) {
if (isMac) { if (isMac) {
name = name.replace('Ctrl', 'Cmd'); name = name.replace('Ctrl', 'Cmd');
} else { } else {
...@@ -1042,7 +1059,7 @@ ...@@ -1042,7 +1059,7 @@
/** /**
* Create icon element for toolbar. * Create icon element for toolbar.
*/ */
function createIcon(options) { function createIcon (options) {
if (options.name === 'image') { if (options.name === 'image') {
return $(options.html)[0]; return $(options.html)[0];
} }
...@@ -1074,7 +1091,7 @@ ...@@ -1074,7 +1091,7 @@
return el; return el;
} }
function createSep() { function createSep () {
el = document.createElement('i'); el = document.createElement('i');
el.className = 'separator'; el.className = 'separator';
el.innerHTML = '|'; el.innerHTML = '|';
...@@ -1085,7 +1102,7 @@ ...@@ -1085,7 +1102,7 @@
/** /**
* The state of CodeMirror at the given position. * The state of CodeMirror at the given position.
*/ */
function getState(cm, pos) { function getState (cm, pos) {
pos = pos || cm.getCursor('start'); pos = pos || cm.getCursor('start');
var stat = cm.getTokenAt(pos); var stat = cm.getTokenAt(pos);
if (!stat.type) if (!stat.type)
...@@ -1118,7 +1135,7 @@ ...@@ -1118,7 +1135,7 @@
/** /**
* Toggle full screen of the editor. * Toggle full screen of the editor.
*/ */
function toggleFullScreen(editor) { function toggleFullScreen (editor) {
var cm = editor.codemirror, var cm = editor.codemirror,
wrap = editor.codemirror.getWrapperElement(); wrap = editor.codemirror.getWrapperElement();
...@@ -1137,8 +1154,10 @@ ...@@ -1137,8 +1154,10 @@
'right': '0' 'right': '0'
}); });
cm.state.fullScreenRestore = {scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset, cm.state.fullScreenRestore = {
width: wrap.style.width, height: wrap.style.height}; scrollTop: window.pageYOffset, scrollLeft: window.pageXOffset,
width: wrap.style.width, height: wrap.style.height
};
wrap.style.width = "50%"; wrap.style.width = "50%";
wrap.style.height = ($(window).height() - $('.editor-toolbar').outerHeight()) + 'px'; wrap.style.height = ($(window).height() - $('.editor-toolbar').outerHeight()) + 'px';
cm.refresh(); cm.refresh();
...@@ -1155,6 +1174,7 @@ ...@@ -1155,6 +1174,7 @@
+ ($(window).height() - $('.editor-toolbar').outerHeight()) + 'px">' + result.html + '</div>'); + ($(window).height() - $('.editor-toolbar').outerHeight()) + 'px">' + result.html + '</div>');
hljs.initHighlighting.called = false; hljs.initHighlighting.called = false;
hljs.initHighlighting(); hljs.initHighlighting();
Util.parseMarkdown();
} }
}); });
...@@ -1179,7 +1199,7 @@ ...@@ -1179,7 +1199,7 @@
/** /**
* Action for toggling bold. * Action for toggling bold.
*/ */
function toggleBold(editor) { function toggleBold (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
var stat = getState(cm); var stat = getState(cm);
...@@ -1214,7 +1234,7 @@ ...@@ -1214,7 +1234,7 @@
/** /**
* Action for toggling italic. * Action for toggling italic.
*/ */
function toggleItalic(editor) { function toggleItalic (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
var stat = getState(cm); var stat = getState(cm);
...@@ -1249,7 +1269,7 @@ ...@@ -1249,7 +1269,7 @@
/** /**
* Action for toggling blockquote. * Action for toggling blockquote.
*/ */
function toggleBlockquote(editor) { function toggleBlockquote (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
_toggleLine(cm, 'quote'); _toggleLine(cm, 'quote');
} }
...@@ -1258,7 +1278,7 @@ ...@@ -1258,7 +1278,7 @@
/** /**
* Action for toggling ul. * Action for toggling ul.
*/ */
function toggleUnOrderedList(editor) { function toggleUnOrderedList (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
_toggleLine(cm, 'unordered-list'); _toggleLine(cm, 'unordered-list');
} }
...@@ -1267,7 +1287,7 @@ ...@@ -1267,7 +1287,7 @@
/** /**
* Action for toggling ol. * Action for toggling ol.
*/ */
function toggleOrderedList(editor) { function toggleOrderedList (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
_toggleLine(cm, 'ordered-list'); _toggleLine(cm, 'ordered-list');
} }
...@@ -1276,7 +1296,7 @@ ...@@ -1276,7 +1296,7 @@
/** /**
* Action for drawing a link. * Action for drawing a link.
*/ */
function drawLink(editor) { function drawLink (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
var stat = getState(cm); var stat = getState(cm);
_replaceSelection(cm, stat.link, '[', '](http://)'); _replaceSelection(cm, stat.link, '[', '](http://)');
...@@ -1286,7 +1306,7 @@ ...@@ -1286,7 +1306,7 @@
/** /**
* Action for drawing an img. * Action for drawing an img.
*/ */
function drawImage(editor) { function drawImage (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
var stat = getState(cm); var stat = getState(cm);
_replaceSelection(cm, stat.image, '![', '](http://)'); _replaceSelection(cm, stat.image, '![', '](http://)');
...@@ -1296,7 +1316,7 @@ ...@@ -1296,7 +1316,7 @@
/** /**
* Undo action. * Undo action.
*/ */
function undo(editor) { function undo (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
cm.undo(); cm.undo();
cm.focus(); cm.focus();
...@@ -1306,7 +1326,7 @@ ...@@ -1306,7 +1326,7 @@
/** /**
* Redo action. * Redo action.
*/ */
function redo(editor) { function redo (editor) {
var cm = editor.codemirror; var cm = editor.codemirror;
cm.redo(); cm.redo();
cm.focus(); cm.focus();
...@@ -1315,7 +1335,7 @@ ...@@ -1315,7 +1335,7 @@
/** /**
* Preview action. * Preview action.
*/ */
function togglePreview(editor) { function togglePreview (editor) {
var toolbar = editor.toolbar.preview; var toolbar = editor.toolbar.preview;
var cm = editor.codemirror; var cm = editor.codemirror;
var wrapper = cm.getWrapperElement(); var wrapper = cm.getWrapperElement();
...@@ -1353,11 +1373,12 @@ ...@@ -1353,11 +1373,12 @@
preview.innerHTML = result.html; preview.innerHTML = result.html;
hljs.initHighlighting.called = false; hljs.initHighlighting.called = false;
hljs.initHighlighting(); hljs.initHighlighting();
Util.parseMarkdown();
} }
}); });
} }
function _replaceSelection(cm, active, start, end) { function _replaceSelection (cm, active, start, end) {
var text; var text;
var startPoint = cm.getCursor('start'); var startPoint = cm.getCursor('start');
var endPoint = cm.getCursor('end'); var endPoint = cm.getCursor('end');
...@@ -1378,7 +1399,7 @@ ...@@ -1378,7 +1399,7 @@
} }
function _toggleLine(cm, name) { function _toggleLine (cm, name) {
var stat = getState(cm); var stat = getState(cm);
var startPoint = cm.getCursor('start'); var startPoint = cm.getCursor('start');
var endPoint = cm.getCursor('end'); var endPoint = cm.getCursor('end');
...@@ -1408,7 +1429,7 @@ ...@@ -1408,7 +1429,7 @@
/* The right word count in respect for CJK. */ /* The right word count in respect for CJK. */
function wordCount(data) { function wordCount (data) {
var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g; var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
var m = data.match(pattern); var m = data.match(pattern);
var count = 0; var count = 0;
...@@ -1446,7 +1467,7 @@ ...@@ -1446,7 +1467,7 @@
/** /**
* Interface of Editor. * Interface of Editor.
*/ */
function Editor(options) { function Editor (options) {
options = options || {}; options = options || {};
if (options.element) { if (options.element) {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
* *
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a> * @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.0.0, May 21, 2017 * @version 1.4.0.0, Nov 10, 2017
*/ */
var Page = function (tips) { var Page = function (tips) {
this.currentCommentId = ""; this.currentCommentId = "";
...@@ -422,7 +422,7 @@ $.extend(Page.prototype, { ...@@ -422,7 +422,7 @@ $.extend(Page.prototype, {
} catch (e) { } catch (e) {
document.write("<script src=\"" + latkeConfig.staticServePath + "/js/lib/json2.js\"><\/script>"); document.write("<script src=\"" + latkeConfig.staticServePath + "/js/lib/json2.js\"><\/script>");
} }
Util.parseMarkdown();
}, },
/* /*
* @description 加载随机文章 * @description 加载随机文章
...@@ -672,8 +672,7 @@ $.extend(Page.prototype, { ...@@ -672,8 +672,7 @@ $.extend(Page.prototype, {
event.preventDefault(); event.preventDefault();
} }
}); });
$("#replyForm #captcha").attr("id", "captchaReply"). $("#replyForm #captcha").attr("id", "captchaReply").attr("src", latkeConfig.servePath + "/captcha.do?" + new Date().getTime()).click(function () {
attr("src", latkeConfig.servePath + "/captcha.do?" + new Date().getTime()).click(function () {
$(this).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random()); $(this).attr("src", latkeConfig.servePath + "/captcha.do?code=" + Math.random());
}); });
$("#replyForm #commentErrorTip").attr("id", "commentErrorTipReply").html("").hide(); $("#replyForm #commentErrorTip").attr("id", "commentErrorTipReply").html("").hide();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment