Browse Source

Edit README.md & Gulp task

v1.1.9
Pandao 10 years ago
parent
commit
497b8db305
  1. 2
      README.md
  2. 2
      dist/css/editormd.css
  3. 2
      dist/css/editormd.css.map
  4. 2
      dist/css/editormd.css.min.map
  5. 2
      dist/css/editormd.min.css
  6. 2
      dist/css/editormd.preview.css
  7. 2
      dist/css/editormd.preview.css.map
  8. 2
      dist/css/editormd.preview.css.min.map
  9. 2
      dist/css/editormd.preview.min.css
  10. 364
      dist/js/editormd.js
  11. 4
      dist/js/editormd.min.js
  12. 8
      docs/html/index.html

2
README.md

@ -59,7 +59,9 @@ javascript:
- [jQuery](http://jquery.com/ "jQuery")
- [FontAwesome](http://fontawesome.io/ "FontAwesome")
- [github-markdown.css](https://github.com/sindresorhus/github-markdown-css "github-markdown.css")
- [KaTeX](http://khan.github.io/KaTeX/ "KaTeX")
- [prettify.js](http://code.google.com/p/google-code-prettify/ "prettify.js")
- [Rephael.js](http://raphaeljs.com/ "Rephael.js")
- [flowchart.js](http://adrai.github.io/flowchart.js/ "flowchart.js")
- [sequence-diagram.js](http://bramp.github.io/js-sequence-diagrams/ "sequence-diagram.js")

2
dist/css/editormd.css

@ -6,7 +6,7 @@
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-09
* @updateTime 2015-02-10
*/
/*!

2
dist/css/editormd.css.map

@ -6,7 +6,7 @@
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-09
* @updateTime 2015-02-10
*/
{

2
dist/css/editormd.css.min.map

File diff suppressed because one or more lines are too long

2
dist/css/editormd.min.css

@ -1,4 +1,4 @@
/*! Editor.md v1.0.0 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-09 */
/*! Editor.md v1.0.0 | editormd.min.css | A simple online markdown editor. | MIT License | By: Pandao | https://github.com/pandao/editor.md | 2015-02-10 */
/*!
* Font Awesome 4.3.0 by @davegandy - http://fontawesome.io - @fontawesome
* License - http://fontawesome.io/license (Font: SIL OFL 1.1, CSS: MIT License)

2
dist/css/editormd.preview.css

@ -6,7 +6,7 @@
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-09
* @updateTime 2015-02-10
*/
/*! github-markdown-css | The MIT License (MIT) | Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com) | https://github.com/sindresorhus/github-markdown-css */

2
dist/css/editormd.preview.css.map

@ -6,7 +6,7 @@
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-09
* @updateTime 2015-02-10
*/
{

2
dist/css/editormd.preview.css.min.map

File diff suppressed because one or more lines are too long

2
dist/css/editormd.preview.min.css

File diff suppressed because one or more lines are too long

364
dist/js/editormd.js

@ -6,7 +6,7 @@
* @license MIT License
* @author Pandao
* {@link https://github.com/pandao/editor.md}
* @updateTime 2015-02-08
* @updateTime 2015-02-10
*/
/**
@ -70,8 +70,8 @@
toc : true,
tocStartLevel : 2,
fontSize : "13px",
tex : false,
flowChart : false, // flowChart.js only support IE9+
mathjax : false,
sequenceDiagram : false, // sequenceDiagram.js only support IE9+
previewCodeHighlight : true,
inRequirejs : false,
@ -144,60 +144,14 @@
fullscreen : "全屏(按ESC还原)",
info : "关于" + editormd.title
}
},
codemirror : {
modes : [
"css",
"sass",
"shell",
"sql",
"clike",
"php",
"xml",
"markdown",
"javascript",
"htmlmixed",
"gfm",
"http",
"go",
"dart",
"coffeescript",
"nginx",
"python",
"perl",
"lua",
//"r",
"ruby",
"rst",
"smartymixed",
//"vb",
//"vbscript",
//"velocity",
//"xquery",
"yaml"
],
addons : [
"edit/trailingspace",
"dialog/dialog",
"search/searchcursor",
"search/search",
"scroll/annotatescrollbar",
"search/matchesonscrollbar",
"display/placeholder",
"edit/closetag",
"fold/xml-fold",
"mode/overlay",
"selection/active-line",
"edit/closebrackets",
"display/fullscreen",
"search/searchcursor",
"search/match-highlighter"
]
}
};
editormd.classNames = {
tex : editormd.classPrefix + "tex"
};
editormd.$katex = null;
editormd.$marked = null;
editormd.$CodeMirror = null;
editormd.$prettyPrint = null;
@ -276,7 +230,7 @@
}
else
{
_this.setCodeEditor();
_this.setCodeMirror();
_this.setToolbar();
_this.toolbarHandler();
_this.setMarked().loadedDisplay();
@ -293,8 +247,6 @@
loadQueues : function() {
var _this = this;
var settings = this.settings;
var cmModeIndex = 0, cmModeTotal = settings.codemirror.modes.length;
var cmAddonIndex = 0, cmAddonTotal = settings.codemirror.addons.length;
var loadPath = settings.path;
var loadFlowChartOrSequenceDiagram = function() {
@ -339,28 +291,23 @@
}
};
var loadCodeMirrorAddons = function() {
var addonName = settings.codemirror.addons[cmAddonIndex];
editormd.loadScript(loadPath + "codemirror/addon/" + addonName, function() {
if(cmAddonIndex < cmAddonTotal - 1)
{
cmAddonIndex ++;
loadCodeMirrorAddons();
}
else
{
_this.setCodeEditor();
_this.setToolbar();
editormd.loadCSS(loadPath + "codemirror/codemirror.min");
editormd.loadScript(loadPath + "codemirror/codemirror.min", function() {
editormd.$CodeMirror = CodeMirror;
editormd.loadScript(loadPath + "codemirror/modes.min", function() {
editormd.loadScript(loadPath + "codemirror/addons.min", function() {
_this.setCodeMirror();
_this.setToolbar();
_this.toolbarHandler();
editormd.loadScript(loadPath + "marked.min", function() {
editormd.$marked = marked;
//_this.marked = marked;
if (settings.previewCodeHighlight)
{
editormd.loadScript(loadPath + "prettify.min", function() {
@ -372,33 +319,11 @@
loadFlowChartOrSequenceDiagram();
}
});
}
});
};
var loadCodeMirrorModes = function(){
var modeName = settings.codemirror.modes[cmModeIndex];
editormd.loadScript(loadPath + "codemirror/mode/" + modeName + "/" + modeName, function() {
if(cmModeIndex < cmModeTotal - 1)
{
cmModeIndex ++;
loadCodeMirrorModes();
}
else
{
loadCodeMirrorAddons();
}
});
});
};
//editormd.loadCSS(loadPath + "font-awesome.min");
editormd.loadCSS(loadPath + "codemirror/lib/codemirror.min");
editormd.loadScript(loadPath + "codemirror/lib/codemirror.min", function() {
editormd.$CodeMirror = CodeMirror;
loadCodeMirrorModes();
});
return this;
@ -409,7 +334,7 @@
* @returns {editormd} 返回editormd的实例对象
*/
setCodeEditor : function() {
setCodeMirror : function() {
var settings = this.settings;
var codeMirrorConfig = {
@ -822,12 +747,24 @@
if (settings.sequenceDiagram) {
previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
}
if (settings.mathjax)
{
editormd.setMathJaxConfig(function() {
editormd.loadMathJax();
var katexHandle = function() {
previewContainer.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
};
if (settings.tex)
{
if (!settings.inRequirejs) {
editormd.loadKaTex(function(){
editormd.$katex = katex;
katexHandle();
});
} else {
katexHandle();
}
}
editor.data({
@ -921,21 +858,9 @@
if (settings.sequenceDiagram) {
previewContainer.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
}
if (settings.mathjax)
{
MathJax.Hub.Queue(function () {
previewContainer.find(".mathjax-code").each(function() {
var mathjaxDoc = $(this).html().replace(/\$\$(.*)\$\$/, function(s1, s2) { return s2; });
var jaxScript = "<script type=\"math/tex; mode=display\">" + mathjaxDoc + "</script>";
$(this).html($(jaxScript));
//MathJax.Hub.Queue(["Typeset", MathJax.Hub, "mathjax-code"]);
MathJax.Hub.Queue(["Typeset", MathJax.Hub, $(this)[0]]);
});
});
if (settings.tex) {
katexHandle();
}
$.proxy(settings.onchange, _this)();
@ -1367,8 +1292,6 @@
markedRenderer.heading = function(text, level, raw) {
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
//console.log("escapedText", text, escapedText, level, raw);
var toc = {
text : text,
level : level,
@ -1377,27 +1300,35 @@
markdownToC.push(toc);
return "<h" + level + " id=\""+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+"\"><a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a><span class=\"header-link\"></span>" + text + "</h" + level + ">";
};
var mathJaxList = [];
return "<h" + level + " id=\"" + this.options.headerPrefix + raw.toLowerCase().replace(/[^\w]+/g,"-")+"\">" +
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";
};
markedRenderer.paragraph = function(text) {
var isMathJax = /\$\$(.*)\$\$/.test(text);
var mathjaxClassName = (isMathJax) ? " class=\"mathjax-code\"" : "";
var isToC = /^\[TOC\]$/.test(text);
if (isMathJax) {
mathJaxList.push(text);
var isTeXInline = /\$\$(.*)\$\$/g.test(text);
var isTeXLine = /^\$\$(.*)\$\$$/.test(text);
var isTeXAddClass = (isTeXLine) ? " class=\"" + editormd.classNames.tex + "\"" : "";
var isToC = /^\[TOC\]$/.test(text);
if (!isTeXLine && isTeXInline)
{
text = text.replace(/(\$\$([^\$]*)\$\$)+/g, function($1, $2) {
return "<span class=\"" + editormd.classNames.tex + "\">" + $2.replace(/\$/g, "") + "</span>";
});
}
else
{
text = (isTeXLine) ? text.replace(/\$/g, "") : text;
}
return (isToC) ? "<div class=\"markdown-toc\"><ul class=\"markdown-toc-list\">" + text + "</ul></div>" : "<p" + mathjaxClassName + ">" + text + "</p>\n";
return (isToC) ? "<div class=\"markdown-toc\"><ul class=\"markdown-toc-list\">" + text + "</ul></div>"
: "<p" + isTeXAddClass + ">" + text + "</p>\n";
};
markedRenderer.code = function (code, lang, escaped) {
if (lang === "seq")
if (lang === "seq" || lang === "sequence")
{
return "<div class=\"sequence-diagram\">" + code + "</div>";
}
@ -1470,10 +1401,11 @@
toc : true,
tocStartLevel : 2,
markdown : "",
mathjax : false,
previewCodeHighlight : true,
inRequirejs : false,
tex : false,
flowChart : false,
sequenceDiagram : false
sequenceDiagram : false,
previewCodeHighlight : true
};
editormd.$marked = marked;
@ -1517,24 +1449,92 @@
div.find(".sequence-diagram").sequenceDiagram({theme: "simple"});
}
if (settings.mathjax)
if (settings.tex)
{
editormd.setMathJaxConfig(function() {
editormd.loadMathJax();
});
var katexHandle = function() {
div.find("." + editormd.classNames.tex).each(function(){
var tex = $(this);
editormd.$katex.render(tex.html(), tex[0]);
});
};
if (!settings.inRequirejs) {
editormd.loadKaTex(function(){
editormd.$katex = katex;
katexHandle();
});
} else {
katexHandle();
}
}
};
// for Requires.js
// 与Gulpfile.js对应
editormd.codeMirrorModules = {
modes : [
"css",
"sass",
"shell",
"sql",
"clike",
"php",
"xml",
"markdown",
"javascript",
"htmlmixed",
"gfm",
"http",
"go",
"dart",
"coffeescript",
"nginx",
"python",
"perl",
"lua",
"r",
"ruby",
"rst",
"smartymixed",
"vb",
"vbscript",
"velocity",
"xquery",
"yaml",
"erlang",
"jade",
],
addons : [
"edit/trailingspace",
"dialog/dialog",
"search/searchcursor",
"search/search",
"scroll/annotatescrollbar",
"search/matchesonscrollbar",
"display/placeholder",
"edit/closetag",
"fold/xml-fold",
"mode/overlay",
"selection/active-line",
"edit/closebrackets",
"display/fullscreen",
"search/searchcursor",
"search/match-highlighter"
]
};
/**
* 用于支持Require.js加载的方法
* 用于支持Require.js加载的方法注入
* @param {Function} CodeMirror CodeMirror对象
* @param {Function} marked marked对象
* @param {Function} prettyPrint prettyPrint函数
*/
editormd.requirejsInit = function(CodeMirror, marked, prettyPrint) {
editormd.requirejsInit = function(CodeMirror, marked, katex, prettyPrint) {
editormd.$CodeMirror = CodeMirror;
editormd.$marked = marked;
editormd.$katex = katex;
editormd.$prettyPrint = prettyPrint;
};
@ -1549,19 +1549,25 @@
var settings = editormd.defaults;
var modules = [];
modules.push(loadPath + "codemirror/lib/codemirror.min");
modules.push(loadPath + "codemirror/codemirror.min");
for (var i = 0, len = settings.codemirror.modes.length; i < len; i++)
var codeMirrorModules = editormd.codeMirrorModules;
for (var i = 0, len = codeMirrorModules.modes.length; i < len; i++)
{
var modeName = settings.codemirror.modes[i];
var modeName = codeMirrorModules.modes[i];
modules.push(loadPath + "codemirror/mode/" + modeName + "/" + modeName);
}
for (var i = 0, len = settings.codemirror.addons.length; i < len; i++)
for (var i = 0, len = codeMirrorModules.addons.length; i < len; i++)
{
var addonName = settings.codemirror.addons[i];
var addonName = codeMirrorModules.addons[i];
modules.push(loadPath + "codemirror/addon/" + addonName);
}
editormd.loadCSS(editormd.katexURL.css);
//modules.push(editormd.katexURL.js + ".js");
return modules;
};
@ -1635,61 +1641,21 @@
}
};
/**
* MathJax配置信息
* @param {Function} [callback=function()] 加载成功后执行的回调函数
*/
editormd.setMathJaxConfig = function (callback) {
callback = callback || function() {};
var script = document.createElement("script");
script.className = "mathjax-config";
script.type = "text/x-mathjax-config";
script.text = 'MathJax.Hub.Config({' +
'extensions: ["tex2jax.js"],'+
'jax: ["input/TeX","output/HTML-CSS"],'+
'tex2jax: {inlineMath: [["$","$"],["\\(","\\)"]]}'+
'});';
document.getElementsByTagName("head")[0].appendChild(script);
callback();
// 使用国外的CDN,加载速度有时会很慢,或者自定义URL
editormd.katexURL = {
css : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min",
js : "//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.1.1/katex.min",
};
// 注:国内可以采用这个CDN,http://cdn.bootcss.com/mathjax/2.4.0/MathJax.js?config=TeX-AMS-MML_HTMLorMML
editormd.mathjaxURL = "http://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";
/**
* 加载MathJax文件
* 加载KaTex文件
* @param {Function} [callback=function()] 加载成功后执行的回调函数
*/
editormd.loadMathJax = function (callback) {
callback = callback || function() {};
var script = document.createElement("script");
script.type = "text/javascript";
script.className = "mathjax-script";
script.onload = script.onreadystatechange = function() {
if (script.readyState)
{
if (script.readyState === "loaded" || script.readyState === "complete")
{
script.onreadystatechange = null;
callback();
}
}
else
{
callback();
}
};
script.src = editormd.mathjaxURL;
document.getElementsByTagName("head")[0].appendChild(script);
editormd.loadKaTex = function (callback) {
editormd.loadCSS(editormd.katexURL.css, function(){
editormd.loadScript(editormd.katexURL.js, callback || function(){});
});
};
/**

4
dist/js/editormd.min.js

File diff suppressed because one or more lines are too long

8
docs/html/index.html

@ -49,9 +49,9 @@
<ul>
<li>支持Markdown标准和Github风格;</li>
<li>支持实时预览和多语言语法高亮;</li>
<li>支持ToC(Table of Contents);</li>
<li>支持<a href="https://pandao.github.io/editor.md/examples/toc.html">ToC(Table of Contents)</a></li>
<li>兼容主流的浏览器(IE8+),且支持iPad等平板设备;</li>
<li>支持Latex科学公式(基于MathJax);</li>
<li>支持TeX科学公式(基于<a href="https://pandao.github.io/editor.md/examples/katex.html">KaTeX</a>);</li>
<li>支持流程图 <code>flowchart</code> 和时序图 <code>sequenceDiagram</code>;</li>
<li>支持AMD/CMD模块化加载(支持 <a href="https://pandao.github.io/editor.md/examples/use-requirejs.html">Require.js</a> &amp; <a href="https://pandao.github.io/editor.md/examples/use-seajs.html">Sea.js</a>);</li>
</ul>
@ -88,7 +88,9 @@
<li><a href="http://jquery.com/" title="jQuery">jQuery</a></li>
<li><a href="http://fontawesome.io/" title="FontAwesome">FontAwesome</a></li>
<li><a href="https://github.com/sindresorhus/github-markdown-css" title="github-markdown.css">github-markdown.css</a></li>
<li><a href="http://khan.github.io/KaTeX/" title="KaTeX">KaTeX</a></li>
<li><a href="http://code.google.com/p/google-code-prettify/" title="prettify.js">prettify.js</a></li>
<li><a href="http://raphaeljs.com/" title="Rephael.js">Rephael.js</a></li>
<li><a href="http://adrai.github.io/flowchart.js/" title="flowchart.js">flowchart.js</a></li>
<li><a href="http://bramp.github.io/js-sequence-diagrams/" title="sequence-diagram.js">sequence-diagram.js</a></li>
</ul>
@ -114,7 +116,7 @@
<br clear="both">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Sat Feb 07 2015 21:21:44 GMT+0800 (中国标准时间)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.3.0-alpha5</a> on Tue Feb 10 2015 00:44:02 GMT+0800 (中国标准时间)
</footer>
<script> prettyPrint(); </script>

Loading…
Cancel
Save