mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-03 03:40:49 +08:00
init project
This commit is contained in:
63
public/editormd/tests/bootstrap-test.html
Normal file
63
public/editormd/tests/bootstrap-test.html
Normal file
@@ -0,0 +1,63 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>Bootstrap 兼容测试 - Editor.md tests</title>
|
||||
<!-- Latest compiled and minified CSS -->
|
||||
<link rel="stylesheet" href="./css/bootstrap.min.css">
|
||||
|
||||
<!-- Optional theme -->
|
||||
<link rel="stylesheet" href="./css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="../css/editormd.css" />
|
||||
<link rel="shortcut icon" href="https://pandao.github.io/editor.md/favicon.ico" type="image/x-icon" />
|
||||
<style>
|
||||
header {width: 90%;margin: 0 auto 20px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout">
|
||||
<header>
|
||||
<h1>Bootstrap 兼容测试</h1>
|
||||
</header>
|
||||
<div id="test-editormd">
|
||||
<textarea style="display:none;">### Bootstrap 兼容测试</textarea>
|
||||
</div>
|
||||
</div>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
|
||||
<!-- Latest compiled and minified JavaScript -->
|
||||
<script src="./js/bootstrap.min.js"></script>
|
||||
<script src="../editormd.js"></script>
|
||||
<script type="text/javascript">
|
||||
var testEditor;
|
||||
|
||||
$(function() {
|
||||
|
||||
$.get("../examples/test.md", function(md){
|
||||
testEditor = editormd("test-editormd", {
|
||||
width: "90%",
|
||||
height: 740,
|
||||
path : '../lib/',
|
||||
markdown : md,
|
||||
codeFold : true,
|
||||
saveHTMLToTextarea : true,
|
||||
searchReplace : true,
|
||||
htmlDecode : "style,script,iframe|on*",
|
||||
emoji : true,
|
||||
taskList : true,
|
||||
tocm : true, // Using [TOCM]
|
||||
tex : true, // 开启科学公式TeX语言支持,默认关闭
|
||||
flowChart : true, // 开启流程图支持,默认关闭
|
||||
sequenceDiagram : true, // 开启时序/序列图支持,默认关闭,
|
||||
imageUpload : true,
|
||||
imageFormats : ["jpg", "jpeg", "gif", "png", "bmp", "webp"],
|
||||
imageUploadURL : "../examples/php/upload.php",
|
||||
onload : function() {
|
||||
console.log('onload', this);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
109
public/editormd/tests/codemirror-searchbox-test.html
Normal file
109
public/editormd/tests/codemirror-searchbox-test.html
Normal file
@@ -0,0 +1,109 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>CodeMirror searchbox Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../examples/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout">
|
||||
<textarea id="test" style="display:none;">###Hello world!</textarea>
|
||||
</div>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="../lib/codemirror/codemirror.min.css" />
|
||||
<script src="../lib/codemirror/codemirror.min.js"></script>
|
||||
<script src="../lib/codemirror/modes.min.js"></script>
|
||||
<script src="../lib/codemirror/addons.min.js"></script>
|
||||
<script src="js/searchbox.js"></script>
|
||||
<style>
|
||||
html, body, #layout, .CodeMirror {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
font-family: Consolas;
|
||||
font-size: 13px;
|
||||
}
|
||||
.ace_search {
|
||||
font-family:"微软雅黑",Arial;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
|
||||
.ace_replacebtn, .ace_button {
|
||||
padding: 0 5px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.ace_button {
|
||||
border-radius: 3px;
|
||||
padding: 2px 5px;
|
||||
margin-left: 3px;
|
||||
}
|
||||
|
||||
.ace_button.checked {
|
||||
border-color: #ccc;
|
||||
background-color: #fafafa;
|
||||
|
||||
}
|
||||
|
||||
.ace_search {
|
||||
display: inline-block;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
.ace_search_form, .ace_replace_form {
|
||||
display: inline-block;
|
||||
float: none;
|
||||
}
|
||||
|
||||
.ace_search_options {
|
||||
display: block;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
var enableSearchbox = true;
|
||||
var codeMirrorConfig = {
|
||||
mode: "gfm",
|
||||
theme: "default",
|
||||
tabSize: 4,
|
||||
dragDrop: false,
|
||||
autofocus: true,
|
||||
indentUnit : 4,
|
||||
searchbox: enableSearchbox, // IE9+
|
||||
lineNumbers: true,
|
||||
lineWrapping: true,
|
||||
matchBrackets: true,
|
||||
indentWithTabs: true,
|
||||
styleActiveLine: true,
|
||||
styleSelectedText: true,
|
||||
autoCloseBrackets: true,
|
||||
showTrailingSpace: true,
|
||||
highlightSelectionMatches: {
|
||||
showToken: /\w/
|
||||
}
|
||||
};
|
||||
|
||||
$.get("../examples/test.md", function(md){
|
||||
$("#test").html(md);
|
||||
|
||||
var codeMirrorEditor = CodeMirror.fromTextArea($("#test")[0], codeMirrorConfig);
|
||||
var codeMirror = $(".CodeMirror");
|
||||
|
||||
$(window).keydown(function() {
|
||||
if (!enableSearchbox) return false;
|
||||
|
||||
$(".ace_replacebtn").eq(0).html("替换");
|
||||
$(".ace_replacebtn").eq(1).html("全部替换");
|
||||
$(".ace_searchbtn").eq(2).remove();//.html("全部").css({width: "36px", padding :"0 4px"});
|
||||
|
||||
$(".ace_button").eq(0).html("正则搜索");
|
||||
$(".ace_button").eq(1).html("区分大小写");
|
||||
$(".ace_button").eq(2).html("全词搜索");
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
75
public/editormd/tests/codemirror-test.html
Normal file
75
public/editormd/tests/codemirror-test.html
Normal file
@@ -0,0 +1,75 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>CodeMirror Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../examples/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="layout">
|
||||
<textarea id="test" style="display:none;">###Hello world!</textarea>
|
||||
</div>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="../lib/codemirror/lib/codemirror.min.css" />
|
||||
<script src="../lib/codemirror/lib/codemirror.min.js"></script>
|
||||
<script src="../lib/codemirror/addons.min.js"></script>
|
||||
<script src="../lib/codemirror/modes.min.js"></script>
|
||||
<!-- <script src="../lib/codemirror-5.0/addon/edit/closetag.js"></script>
|
||||
<script src="../lib/codemirror-5.0/addon/fold/xml-fold.js"></script>
|
||||
<script src="../lib/codemirror-5.0/mode/xml/xml.js"></script>
|
||||
<script src="../lib/codemirror-5.0/mode/javascript/javascript.js"></script>
|
||||
<script src="../lib/codemirror-5.0/mode/css/css.js"></script>
|
||||
<script src="../lib/codemirror-5.0/mode/htmlmixed/htmlmixed.js"></script>-->
|
||||
<!--<script src="../lib/codemirror/addons.min.js"></script>
|
||||
<script src="../lib/codemirror/modes.min.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="../lib/codemirror/addon/dialog/dialog.css">
|
||||
<link rel="stylesheet" href="../lib/codemirror/addon/search/matchesonscrollbar.css">
|
||||
|
||||
<script src="../lib/codemirror/addon/dialog/dialog.js"></script>
|
||||
<script src="../lib/codemirror/addon/search/searchcursor.js"></script>
|
||||
<script src="../lib/codemirror/addon/search/search.js"></script>
|
||||
<script src="../lib/codemirror/addon/scroll/annotatescrollbar.js"></script>
|
||||
<script src="../lib/codemirror/addon/search/matchesonscrollbar.js"></script>-->
|
||||
<style>
|
||||
html, body, #layout, .CodeMirror {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
|
||||
var codeMirrorConfig = {
|
||||
mode: "gfm",
|
||||
theme: "default",
|
||||
//tabSize: 4,
|
||||
//dragDrop: false,
|
||||
autoCloseTags : true,
|
||||
//autofocus: true,
|
||||
//indentUnit : 4,
|
||||
//lineNumbers: true,
|
||||
//lineWrapping: true,
|
||||
/*matchBrackets: true,
|
||||
indentWithTabs: true,
|
||||
styleActiveLine: true,
|
||||
styleSelectedText: true,
|
||||
autoCloseBrackets: true,
|
||||
showTrailingSpace: true,
|
||||
highlightSelectionMatches: {
|
||||
showToken: /\w/
|
||||
} */
|
||||
};
|
||||
|
||||
$.get("../examples/test.md", function(md){
|
||||
$("#test").html(md);
|
||||
var codeMirrorEditor = CodeMirror.fromTextArea($("#test")[0], codeMirrorConfig);
|
||||
var codeMirror = $(".CodeMirror");
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
5
public/editormd/tests/css/bootstrap-theme.min.css
vendored
Normal file
5
public/editormd/tests/css/bootstrap-theme.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
5
public/editormd/tests/css/bootstrap.min.css
vendored
Normal file
5
public/editormd/tests/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
7
public/editormd/tests/js/bootstrap.min.js
vendored
Normal file
7
public/editormd/tests/js/bootstrap.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
674
public/editormd/tests/js/searchbox.js
Normal file
674
public/editormd/tests/js/searchbox.js
Normal file
@@ -0,0 +1,674 @@
|
||||
/* global CodeMirror */
|
||||
/* global define */
|
||||
|
||||
(function(mod) {
|
||||
'use strict';
|
||||
|
||||
if (typeof exports === 'object' && typeof module === 'object') // CommonJS
|
||||
mod(require('../../lib/codemirror'));
|
||||
else if (typeof define === 'function' && define.amd) // AMD
|
||||
define(['../../lib/codemirror'], mod);
|
||||
else
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
'use strict';
|
||||
|
||||
var Search;
|
||||
|
||||
CodeMirror.defineOption('searchbox', false, function(cm) {
|
||||
cm.addKeyMap({
|
||||
'Ctrl-F': function() {
|
||||
if (!Search)
|
||||
Search = new SearchBox(cm);
|
||||
|
||||
Search.show();
|
||||
},
|
||||
|
||||
'Esc': function() {
|
||||
if (Search && Search.isVisible()) {
|
||||
Search.hide();
|
||||
|
||||
if (typeof event !== 'undefined')
|
||||
event.stopPropagation();
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
'Cmd-F': function() {
|
||||
if (!Search)
|
||||
Search = new SearchBox(cm);
|
||||
|
||||
Search.show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function SearchBox(cm) {
|
||||
var self = this;
|
||||
|
||||
init();
|
||||
|
||||
function initElements(el) {
|
||||
self.searchBox = el.querySelector('.ace_search_form');
|
||||
self.replaceBox = el.querySelector('.ace_replace_form');
|
||||
self.searchOptions = el.querySelector('.ace_search_options');
|
||||
|
||||
self.regExpOption = el.querySelector('[action=toggleRegexpMode]');
|
||||
self.caseSensitiveOption = el.querySelector('[action=toggleCaseSensitive]');
|
||||
self.wholeWordOption = el.querySelector('[action=toggleWholeWords]');
|
||||
|
||||
self.searchInput = self.searchBox.querySelector('.ace_search_field');
|
||||
self.replaceInput = self.replaceBox.querySelector('.ace_search_field');
|
||||
}
|
||||
|
||||
function init() {
|
||||
var el = self.element = addHtml();
|
||||
|
||||
addStyle();
|
||||
|
||||
initElements(el);
|
||||
bindKeys();
|
||||
|
||||
el.addEventListener('mousedown', function(e) {
|
||||
setTimeout(function(){
|
||||
self.activeInput.focus();
|
||||
}, 0);
|
||||
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
el.addEventListener('click', function(e) {
|
||||
var t = e.target || e.srcElement;
|
||||
var action = t.getAttribute('action');
|
||||
if (action && self[action])
|
||||
self[action]();
|
||||
else if (self.commands[action])
|
||||
self.commands[action]();
|
||||
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
self.searchInput.addEventListener('input', function() {
|
||||
self.$onChange.schedule(20);
|
||||
});
|
||||
|
||||
self.searchInput.addEventListener('focus', function() {
|
||||
self.activeInput = self.searchInput;
|
||||
});
|
||||
|
||||
self.replaceInput.addEventListener('focus', function() {
|
||||
self.activeInput = self.replaceInput;
|
||||
});
|
||||
|
||||
self.$onChange = delayedCall(function() {
|
||||
self.find(false, false);
|
||||
});
|
||||
}
|
||||
|
||||
function bindKeys() {
|
||||
var sb = self,
|
||||
obj = {
|
||||
'Ctrl-F|Cmd-F|Ctrl-H|Command-Alt-F': function() {
|
||||
var isReplace = sb.isReplace = !sb.isReplace;
|
||||
sb.replaceBox.style.display = isReplace ? '' : 'none';
|
||||
sb[isReplace ? 'replaceInput' : 'searchInput'].focus();
|
||||
},
|
||||
'Ctrl-G|Cmd-G': function() {
|
||||
sb.findNext();
|
||||
},
|
||||
'Ctrl-Shift-G|Cmd-Shift-G': function() {
|
||||
sb.findPrev();
|
||||
},
|
||||
'Esc': function() {
|
||||
setTimeout(function() { sb.hide();});
|
||||
},
|
||||
'Enter': function() {
|
||||
if (sb.activeInput === sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findNext();
|
||||
},
|
||||
'Shift-Enter': function() {
|
||||
if (sb.activeInput === sb.replaceInput)
|
||||
sb.replace();
|
||||
sb.findPrev();
|
||||
},
|
||||
'Alt-Enter': function() {
|
||||
if (sb.activeInput === sb.replaceInput)
|
||||
sb.replaceAll();
|
||||
sb.findAll();
|
||||
},
|
||||
'Tab': function() {
|
||||
if (self.activeInput === self.replaceInput)
|
||||
self.searchInput.focus();
|
||||
else
|
||||
self.replaceInput.focus();
|
||||
}
|
||||
};
|
||||
|
||||
self.element.addEventListener('keydown', function(event) {
|
||||
Object.keys(obj).some(function(name) {
|
||||
var is = key(name, event);
|
||||
|
||||
if (is) {
|
||||
event.stopPropagation();
|
||||
event.preventDefault();
|
||||
obj[name](event);
|
||||
}
|
||||
|
||||
return is;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
this.commands = {
|
||||
toggleRegexpMode: function() {
|
||||
self.regExpOption.checked = !self.regExpOption.checked;
|
||||
self.$syncOptions();
|
||||
},
|
||||
|
||||
toggleCaseSensitive: function() {
|
||||
self.caseSensitiveOption.checked = !self.caseSensitiveOption.checked;
|
||||
self.$syncOptions();
|
||||
},
|
||||
|
||||
toggleWholeWords: function() {
|
||||
self.wholeWordOption.checked = !self.wholeWordOption.checked;
|
||||
self.$syncOptions();
|
||||
}
|
||||
};
|
||||
|
||||
this.$syncOptions = function() {
|
||||
setCssClass(this.regExpOption, 'checked', this.regExpOption.checked);
|
||||
setCssClass(this.wholeWordOption, 'checked', this.wholeWordOption.checked);
|
||||
setCssClass(this.caseSensitiveOption, 'checked', this.caseSensitiveOption.checked);
|
||||
|
||||
this.find(false, false);
|
||||
};
|
||||
|
||||
this.find = function(skipCurrent, backwards) {
|
||||
var value = this.searchInput.value,
|
||||
options = {
|
||||
skipCurrent: skipCurrent,
|
||||
backwards: backwards,
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked
|
||||
};
|
||||
|
||||
find(value, options, function(searchCursor) {
|
||||
var current = searchCursor.matches(false, searchCursor.from());
|
||||
cm.setSelection(current.from, current.to);
|
||||
});
|
||||
};
|
||||
|
||||
function find(value, options, callback) {
|
||||
var done,
|
||||
noMatch, searchCursor, next, prev, matches, cursor,
|
||||
position,
|
||||
o = options,
|
||||
is = true,
|
||||
caseSensitive = o.caseSensitive,
|
||||
regExp = o.regExp,
|
||||
wholeWord = o.wholeWord;
|
||||
|
||||
if (regExp || wholeWord) {
|
||||
if (options.wholeWord)
|
||||
value = '\\b' + value + '\\b';
|
||||
|
||||
value = RegExp(value);
|
||||
}
|
||||
|
||||
if (o.backwards)
|
||||
position = o.skipCurrent ? 'from': 'to';
|
||||
else
|
||||
position = o.skipCurrent ? 'to' : 'from';
|
||||
|
||||
cursor = cm.getCursor(position);
|
||||
searchCursor = cm.getSearchCursor(value, cursor, !caseSensitive);
|
||||
|
||||
next = searchCursor.findNext.bind(searchCursor),
|
||||
prev = searchCursor.findPrevious.bind(searchCursor),
|
||||
matches = searchCursor.matches.bind(searchCursor);
|
||||
|
||||
if (o.backwards && !prev()) {
|
||||
is = next();
|
||||
|
||||
if (is) {
|
||||
cm.setCursor(cm.doc.size - 1, 0);
|
||||
find(true, true, callback);
|
||||
done = true;
|
||||
}
|
||||
} else if (!o.backwards && !next()) {
|
||||
is = prev();
|
||||
|
||||
if (is) {
|
||||
cm.setCursor(0, 0);
|
||||
find(true, false, callback);
|
||||
done = true;
|
||||
}
|
||||
}
|
||||
|
||||
noMatch = !is && self.searchInput.value;
|
||||
setCssClass(self.searchBox, 'ace_nomatch', noMatch);
|
||||
|
||||
if (!done && is)
|
||||
callback(searchCursor);
|
||||
}
|
||||
|
||||
this.findNext = function() {
|
||||
this.find(true, false);
|
||||
};
|
||||
|
||||
this.findPrev = function() {
|
||||
this.find(true, true);
|
||||
};
|
||||
|
||||
this.findAll = function(){
|
||||
/*
|
||||
var range = this.editor.findAll(this.searchInput.value, {
|
||||
regExp: this.regExpOption.checked,
|
||||
caseSensitive: this.caseSensitiveOption.checked,
|
||||
wholeWord: this.wholeWordOption.checked
|
||||
});
|
||||
*/
|
||||
|
||||
var value = this.searchInput.value,
|
||||
range,
|
||||
noMatch = !range && this.searchInput.value;
|
||||
|
||||
setCssClass(this.searchBox, 'ace_nomatch', noMatch);
|
||||
|
||||
if (cm.showMatchesOnScrollbar)
|
||||
cm.showMatchesOnScrollbar(value);
|
||||
|
||||
this.hide();
|
||||
};
|
||||
|
||||
this.replace = function() {
|
||||
if (!cm.getOption('readOnly'))
|
||||
cm.replaceSelection(this.replaceInput.value, 'start');
|
||||
};
|
||||
|
||||
this.replaceAndFindNext = function() {
|
||||
if (!cm.getOption('readOnly')) {
|
||||
this.editor.replace(this.replaceInput.value);
|
||||
this.findNext();
|
||||
}
|
||||
};
|
||||
|
||||
this.replaceAll = function() {
|
||||
var value,
|
||||
cursor,
|
||||
from = this.searchInput.value,
|
||||
to = this.replaceInput.value,
|
||||
reg = RegExp(from, 'g');
|
||||
|
||||
if (!cm.getOption('readOnly')) {
|
||||
cursor = cm.getCursor();
|
||||
value = cm.getValue();
|
||||
value = value.replace(reg, to);
|
||||
|
||||
cm.setValue(value);
|
||||
cm.setCursor(cursor);
|
||||
}
|
||||
};
|
||||
|
||||
this.hide = function() {
|
||||
this.element.style.display = 'none';
|
||||
cm.focus();
|
||||
};
|
||||
|
||||
this.isVisible = function() {
|
||||
var is = this.element.style.display === '';
|
||||
|
||||
return is;
|
||||
};
|
||||
|
||||
this.show = function(value, isReplace) {
|
||||
this.element.style.display = '';
|
||||
this.replaceBox.style.display = isReplace ? '' : 'none';
|
||||
|
||||
this.isReplace = isReplace;
|
||||
|
||||
if (value)
|
||||
this.searchInput.value = value;
|
||||
|
||||
this.searchInput.focus();
|
||||
this.searchInput.select();
|
||||
};
|
||||
|
||||
this.isFocused = function() {
|
||||
var el = document.activeElement;
|
||||
return el === this.searchInput || el === this.replaceInput;
|
||||
};
|
||||
|
||||
function addStyle() {
|
||||
var style = document.createElement('style'),
|
||||
css = [
|
||||
'.ace_search {',
|
||||
'background-color: #ddd;',
|
||||
'border: 1px solid #cbcbcb;',
|
||||
'border-top: 0 none;',
|
||||
'max-width: 325px;',
|
||||
'overflow: hidden;',
|
||||
'margin: 0;',
|
||||
'padding: 4px;',
|
||||
'padding-right: 6px;',
|
||||
'padding-bottom: 0;',
|
||||
'position: absolute;',
|
||||
'top: 0px;',
|
||||
'z-index: 99;',
|
||||
'white-space: normal;',
|
||||
'}',
|
||||
'.ace_search.left {',
|
||||
'border-left: 0 none;',
|
||||
'border-radius: 0px 0px 5px 0px;',
|
||||
'left: 0;',
|
||||
'}',
|
||||
'.ace_search.right {',
|
||||
'border-radius: 0px 0px 0px 5px;',
|
||||
'border-right: 0 none;',
|
||||
'right: 0;',
|
||||
'}',
|
||||
'.ace_search_form, .ace_replace_form {',
|
||||
'border-radius: 3px;',
|
||||
'border: 1px solid #cbcbcb;',
|
||||
'float: left;',
|
||||
'margin-bottom: 4px;',
|
||||
'overflow: hidden;',
|
||||
'}',
|
||||
'.ace_search_form.ace_nomatch {',
|
||||
'outline: 1px solid red;',
|
||||
'}',
|
||||
'.ace_search_field {',
|
||||
'background-color: white;',
|
||||
'border-right: 1px solid #cbcbcb;',
|
||||
'border: 0 none;',
|
||||
'-webkit-box-sizing: border-box;',
|
||||
'-moz-box-sizing: border-box;',
|
||||
'box-sizing: border-box;',
|
||||
'float: left;',
|
||||
'height: 22px;',
|
||||
'outline: 0;',
|
||||
'padding: 0 7px;',
|
||||
'width: 214px;',
|
||||
'margin: 0;',
|
||||
'}',
|
||||
'.ace_searchbtn,',
|
||||
'.ace_replacebtn {',
|
||||
'background: #fff;',
|
||||
'border: 0 none;',
|
||||
'border-left: 1px solid #dcdcdc;',
|
||||
'cursor: pointer;',
|
||||
'float: left;',
|
||||
'height: 22px;',
|
||||
'margin: 0;',
|
||||
'padding: 0;',
|
||||
'position: relative;',
|
||||
'}',
|
||||
'.ace_searchbtn:last-child,',
|
||||
'.ace_replacebtn:last-child {',
|
||||
'border-top-right-radius: 3px;',
|
||||
'border-bottom-right-radius: 3px;',
|
||||
'}',
|
||||
'.ace_searchbtn:disabled {',
|
||||
'background: none;',
|
||||
'cursor: default;',
|
||||
'}',
|
||||
'.ace_searchbtn {',
|
||||
'background-position: 50% 50%;',
|
||||
'background-repeat: no-repeat;',
|
||||
'width: 27px;',
|
||||
'}',
|
||||
'.ace_searchbtn.prev {',
|
||||
'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADFJREFUeNpiSU1NZUAC/6E0I0yACYskCpsJiySKIiY0SUZk40FyTEgCjGgKwTRAgAEAQJUIPCE+qfkAAAAASUVORK5CYII=); ',
|
||||
'}',
|
||||
'.ace_searchbtn.next {',
|
||||
'background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAFCAYAAAB4ka1VAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADRJREFUeNpiTE1NZQCC/0DMyIAKwGJMUAYDEo3M/s+EpvM/mkKwCQxYjIeLMaELoLMBAgwAU7UJObTKsvAAAAAASUVORK5CYII=); ',
|
||||
'}',
|
||||
'.ace_searchbtn_close {',
|
||||
'background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAcCAYAAABRVo5BAAAAZ0lEQVR42u2SUQrAMAhDvazn8OjZBilCkYVVxiis8H4CT0VrAJb4WHT3C5xU2a2IQZXJjiQIRMdkEoJ5Q2yMqpfDIo+XY4k6h+YXOyKqTIj5REaxloNAd0xiKmAtsTHqW8sR2W5f7gCu5nWFUpVjZwAAAABJRU5ErkJggg==) no-repeat 50% 0;',
|
||||
'border-radius: 50%;',
|
||||
'border: 0 none;',
|
||||
'color: #656565;',
|
||||
'cursor: pointer;',
|
||||
'float: right;',
|
||||
'font: 16px/16px Arial;',
|
||||
'height: 14px;',
|
||||
'margin: 5px 1px 9px 5px;',
|
||||
'padding: 0;',
|
||||
'text-align: center;',
|
||||
'width: 14px;',
|
||||
'}',
|
||||
'.ace_searchbtn_close:hover {',
|
||||
'background-color: #656565;',
|
||||
'background-position: 50% 100%;',
|
||||
'color: white;',
|
||||
'}',
|
||||
'.ace_replacebtn.prev {',
|
||||
'width: 54px',
|
||||
'}',
|
||||
'.ace_replacebtn.next {',
|
||||
'width: 27px',
|
||||
'}',
|
||||
'.ace_button {',
|
||||
'margin-left: 2px;',
|
||||
'cursor: pointer;',
|
||||
'-webkit-user-select: none;',
|
||||
'-moz-user-select: none;',
|
||||
'-o-user-select: none;',
|
||||
'-ms-user-select: none;',
|
||||
'user-select: none;',
|
||||
'overflow: hidden;',
|
||||
'opacity: 0.7;',
|
||||
'border: 1px solid rgba(100,100,100,0.23);',
|
||||
'padding: 1px;',
|
||||
'-moz-box-sizing: border-box;',
|
||||
'box-sizing: border-box;',
|
||||
'color: black;',
|
||||
'}',
|
||||
'.ace_button:hover {',
|
||||
'background-color: #eee;',
|
||||
'opacity:1;',
|
||||
'}',
|
||||
'.ace_button:active {',
|
||||
'background-color: #ddd;',
|
||||
'}',
|
||||
'.ace_button.checked {',
|
||||
'border-color: #3399ff;',
|
||||
'opacity:1;',
|
||||
'}',
|
||||
'.ace_search_options{',
|
||||
'margin-bottom: 3px;',
|
||||
'text-align: right;',
|
||||
'-webkit-user-select: none;',
|
||||
'-moz-user-select: none;',
|
||||
'-o-user-select: none;',
|
||||
'-ms-user-select: none;',
|
||||
'user-select: none;',
|
||||
'}'
|
||||
].join('');
|
||||
|
||||
style.setAttribute('data-name', 'js-searchbox');
|
||||
|
||||
style.textContent = css;
|
||||
|
||||
document.head.appendChild(style);
|
||||
}
|
||||
|
||||
function addHtml() {
|
||||
var elSearch,
|
||||
el = document.querySelector('.CodeMirror'),
|
||||
div = document.createElement('div'),
|
||||
html = [
|
||||
'<div class="ace_search right">',
|
||||
'<button type="button" action="hide" class="ace_searchbtn_close"></button>',
|
||||
'<div class="ace_search_form">',
|
||||
'<input class="ace_search_field" placeholder="Search for" spellcheck="false"></input>',
|
||||
'<button type="button" action="findNext" class="ace_searchbtn next"></button>',
|
||||
'<button type="button" action="findPrev" class="ace_searchbtn prev"></button>',
|
||||
'<button type="button" action="findAll" class="ace_searchbtn" title="Alt-Enter">All</button>',
|
||||
'</div>',
|
||||
'<div class="ace_replace_form">',
|
||||
'<input class="ace_search_field" placeholder="Replace with" spellcheck="false"></input>',
|
||||
'<button type="button" action="replaceAndFindNext" class="ace_replacebtn">Replace</button>',
|
||||
'<button type="button" action="replaceAll" class="ace_replacebtn">All</button>',
|
||||
'</div>',
|
||||
'<div class="ace_search_options">',
|
||||
'<span action="toggleRegexpMode" class="ace_button" title="RegExp Search">.*</span>',
|
||||
'<span action="toggleCaseSensitive" class="ace_button" title="CaseSensitive Search">Aa</span>',
|
||||
'<span action="toggleWholeWords" class="ace_button" title="Whole Word Search">\\b</span>',
|
||||
'</div>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
div.innerHTML = html;
|
||||
|
||||
elSearch = div.firstChild;
|
||||
|
||||
el.parentElement.appendChild(elSearch);
|
||||
|
||||
return elSearch;
|
||||
}
|
||||
}
|
||||
|
||||
function setCssClass(el, className, condition) {
|
||||
var list = el.classList;
|
||||
|
||||
list[condition ? 'add' : 'remove'](className);
|
||||
}
|
||||
|
||||
function delayedCall(fcn, defaultTimeout) {
|
||||
var timer,
|
||||
callback = function() {
|
||||
timer = null;
|
||||
fcn();
|
||||
},
|
||||
|
||||
_self = function(timeout) {
|
||||
if (!timer)
|
||||
timer = setTimeout(callback, timeout || defaultTimeout);
|
||||
};
|
||||
|
||||
_self.delay = function(timeout) {
|
||||
timer && clearTimeout(timer);
|
||||
timer = setTimeout(callback, timeout || defaultTimeout);
|
||||
};
|
||||
_self.schedule = _self;
|
||||
|
||||
_self.call = function() {
|
||||
this.cancel();
|
||||
fcn();
|
||||
};
|
||||
|
||||
_self.cancel = function() {
|
||||
timer && clearTimeout(timer);
|
||||
timer = null;
|
||||
};
|
||||
|
||||
_self.isPending = function() {
|
||||
return timer;
|
||||
};
|
||||
|
||||
return _self;
|
||||
}
|
||||
|
||||
/* https://github.com/coderaiser/key */
|
||||
function key(str, event) {
|
||||
var right,
|
||||
KEY = {
|
||||
BACKSPACE : 8,
|
||||
TAB : 9,
|
||||
ENTER : 13,
|
||||
ESC : 27,
|
||||
|
||||
SPACE : 32,
|
||||
PAGE_UP : 33,
|
||||
PAGE_DOWN : 34,
|
||||
END : 35,
|
||||
HOME : 36,
|
||||
UP : 38,
|
||||
DOWN : 40,
|
||||
|
||||
INSERT : 45,
|
||||
DELETE : 46,
|
||||
|
||||
INSERT_MAC : 96,
|
||||
|
||||
ASTERISK : 106,
|
||||
PLUS : 107,
|
||||
MINUS : 109,
|
||||
|
||||
F1 : 112,
|
||||
F2 : 113,
|
||||
F3 : 114,
|
||||
F4 : 115,
|
||||
F5 : 116,
|
||||
F6 : 117,
|
||||
F7 : 118,
|
||||
F8 : 119,
|
||||
F9 : 120,
|
||||
F10 : 121,
|
||||
|
||||
SLASH : 191,
|
||||
TRA : 192, /* Typewritten Reverse Apostrophe (`) */
|
||||
BACKSLASH : 220
|
||||
};
|
||||
|
||||
keyCheck(str, event);
|
||||
|
||||
right = str.split('|').some(function(combination) {
|
||||
var wrong;
|
||||
|
||||
wrong = combination.split('-').some(function(key) {
|
||||
var right;
|
||||
|
||||
switch(key) {
|
||||
case 'Ctrl':
|
||||
right = event.ctrlKey;
|
||||
break;
|
||||
|
||||
case 'Shift':
|
||||
right = event.shiftKey;
|
||||
break;
|
||||
|
||||
case 'Alt':
|
||||
right = event.altKey;
|
||||
break;
|
||||
|
||||
case 'Cmd':
|
||||
right = event.metaKey;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (key.length === 1)
|
||||
right = event.keyCode === key.charCodeAt(0);
|
||||
else
|
||||
Object.keys(KEY).some(function(name) {
|
||||
var up = key.toUpperCase();
|
||||
|
||||
if (up === name)
|
||||
right = event.keyCode === KEY[name];
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
return !right;
|
||||
});
|
||||
|
||||
return !wrong;
|
||||
});
|
||||
|
||||
return right;
|
||||
}
|
||||
|
||||
function keyCheck(str, event) {
|
||||
if (typeof str !== 'string')
|
||||
throw(Error('str should be string!'));
|
||||
|
||||
if (typeof event !== 'object')
|
||||
throw(Error('event should be object!'));
|
||||
}
|
||||
|
||||
});
|
||||
132
public/editormd/tests/katex-tests.html
Normal file
132
public/editormd/tests/katex-tests.html
Normal file
@@ -0,0 +1,132 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>KaTeX Tests</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<style>
|
||||
* {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
|
||||
body{font-size:14px;color:#444;font-family:"微软雅黑",Arial;background:#fff;padding: 15px;}
|
||||
|
||||
.katex {display: block;margin-bottom: 10px;}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<a href="http://khan.github.io/KaTeX/" target="_blank">http://khan.github.io/KaTeX/</a><br/><br/>
|
||||
<a href="http://meta.wikimedia.org/wiki/Help:Displaying_a_formula" target="_blank">http://meta.wikimedia.org/wiki/Help:Displaying_a_formula</a>
|
||||
<br/><br/>
|
||||
<span class="katex">a^2</span>
|
||||
<span class="katex">a^{2+2}</span>
|
||||
<span class="katex">a_2</span>
|
||||
<span class="katex">{x_2}^3</span>
|
||||
<span class="katex">x_2^3</span>
|
||||
<span class="katex">10^{10^{8}}</span>
|
||||
<span class="katex">a_{i,j}</span>
|
||||
<span class="katex">_nP_k</span>
|
||||
<span class="katex">E=MC^2</span>
|
||||
<span class="katex">\left \{ \frac{a}{b} \right \} \quad \left \lbrace \frac{a}{b} \right \rbrace</span>
|
||||
<span class="katex">\left [ \frac{a}{b} \right ] \quad \left \lbrack \frac{a}{b} \right \rbrack</span>
|
||||
<span class="katex">\left ( \frac{a}{b} \right )</span>
|
||||
<span class="katex">\left \langle \frac{a}{b} \right \rangle</span>
|
||||
<span class="katex">x > y = 100</span>
|
||||
<span class="katex">c = \pm\sqrt{a^2 + b^2}</span>
|
||||
<span class="katex">\left . \frac{A}{B} \right \} \to X</span>
|
||||
<span class="katex">\left / \frac{a}{b} \right \backslash</span>
|
||||
<span class="katex">\left \lfloor \frac{a}{b} \right \rfloor \left \lceil \frac{c}{d} \right \rceil</span>
|
||||
<span class="katex">\frac{1}{2}=0.5</span>
|
||||
<span class="katex">\dfrac{k}{k-1} = 0.5</span>
|
||||
<span class="katex">\dbinom{n}{k} \binom{n}{k}</span>
|
||||
<span class="katex">\oint_C x^3\, dx + 4y^2\, dy</span>
|
||||
<span class="katex">\bigcap_1^n p \bigcup_1^k p</span>
|
||||
<span class="katex">\phi_n(\kappa) =
|
||||
\frac{1}{4\pi^2\kappa^2} \int_0^\infty
|
||||
\frac{\sin(\kappa R)}{\kappa R}
|
||||
\frac{\partial}{\partial R}
|
||||
\left[R^2\frac{\partial D_n(R)}{\partial R}\right]\,dR</span>
|
||||
<span class="katex">\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
|
||||
{3^m\left(m\,3^n+n\,3^m\right)}</span>
|
||||
<span class="katex">e^{i \pi} + 1 = 0</span>
|
||||
<span class="katex">\left ( \frac{1}{2} \right )</span>
|
||||
<span class="katex">x_{1,2}=\frac{-b\pm\sqrt{\color{Red}b^2-4ac}}{2a}</span>
|
||||
<span class="katex">{\color{Blue}x^2}+{\color{YellowOrange}2x}-{\color{OliveGreen}1}</span>
|
||||
<span class="katex">\textstyle \sum_{k=1}^N k^2</span>
|
||||
<span class="katex">\dfrac{ \tfrac{1}{2}[1-(\tfrac{1}{2})^n] }{ 1-\tfrac{1}{2} } = s_n</span>
|
||||
<span class="katex">\binom{n}{k}</span>
|
||||
<span class="katex">0+1+2+3+4+5+6+7+8+9+10+11+12+13+14+15+16+17+18+19+20+\cdots</span>
|
||||
<span class="katex">f(x) = \int_{-\infty}^\infty
|
||||
\hat f(\xi)\,e^{2 \pi i \xi x}
|
||||
\,d\xi</span>
|
||||
<span class="katex">\displaystyle \frac{1}{\Bigl(\sqrt{\phi \sqrt{5}}-\phi\Bigr) e^{\frac25 \pi}} = 1+\frac{e^{-2\pi}} {1+\frac{e^{-4\pi}} {1+\frac{e^{-6\pi}} {1+\frac{e^{-8\pi}} {1+\cdots} } } }</span>
|
||||
<span class="katex">\displaystyle \left( \sum_{k=1}^n a_k b_k \right)^2 \leq \left( \sum_{k=1}^n a_k^2 \right) \left( \sum_{k=1}^n b_k^2 \right)</span>
|
||||
<span class="katex">\displaystyle 1 + \frac{q^2}{(1-q)}+\frac{q^6}{(1-q)(1-q^2)}+\cdots = \prod_{j=0}^{\infty}\frac{1}{(1-q^{5j+2})(1-q^{5j+3})}, \quad\quad \text{for }\lvert q\rvert<1.</span>
|
||||
<span class="katex">2 = \left(
|
||||
\frac{\left(3-x\right) \times 2}{3-x}
|
||||
\right)</span>
|
||||
<span class="katex">S_{\text{new}} = S_{\text{old}} - \frac{ \left( 5-T \right) ^2} {2}</span>
|
||||
<span class="katex">x=\frac{-b\pm\sqrt{b^2-4ac}}{2a}</span>
|
||||
<span class="katex">ax^2 + bx + c = 0\,</span>
|
||||
<span class="katex">\int_a^x \!\!\!\int_a^s f(y)\,dy\,ds
|
||||
= \int_a^x f(y)(x-y)\,dy</span>
|
||||
<span class="katex">\sum_{m=1}^\infty\sum_{n=1}^\infty\frac{m^2\,n}
|
||||
{3^m\left(m\,3^n+n\,3^m\right)}</span>
|
||||
<span class="katex">u'' + p(x)u' + q(x)u=f(x),\quad x>a</span>
|
||||
<span class="katex">|\bar{z}| = |z|,
|
||||
|(\bar{z})^n| = |z|^n,
|
||||
\arg(z^n) = n \arg(z)</span>
|
||||
<span class="katex">\lim_{z\rightarrow z_0} f(z)=f(z_0)</span>
|
||||
<span class="katex">\phi_n(\kappa) =
|
||||
0.033C_n^2\kappa^{-11/3},\quad
|
||||
\frac{1}{L_0}\ll\kappa\ll\frac{1}{l_0}</span>
|
||||
<span class="katex">\sum_{k=1}^N k^2</span>
|
||||
<span class="katex">\textstyle \sum_{k=1}^N k^2</span>
|
||||
<span class="katex">\prod_{i=1}^N x_i</span>
|
||||
<span class="katex">\textstyle \prod_{i=1}^N x_i</span>
|
||||
<span class="katex">\coprod_{i=1}^N x_i</span>
|
||||
<span class="katex">\textstyle \coprod_{i=1}^N x_i</span>
|
||||
<span class="katex">\int_{1}^{3}\frac{e^3/x}{x^2}\, dx</span>
|
||||
<span class="katex">\int_C x^3\, dx + 4y^2\, dy</span>
|
||||
<span class="katex">{}_1^2\!\Omega_3^4</span>
|
||||
<span class="katex">x', y'', f', f''</span>
|
||||
<span class="katex">\dot{x}, \ddot{x}</span>
|
||||
<span class="katex">\hat a \ \bar b \ \vec c</span>
|
||||
<span class="katex">\lessapprox \lesssim \eqslantless \leqslant \leqq \geqq \geqslant \eqslantgtr \gtrsim \gtrapprox</span>
|
||||
<span class="katex">\smile \frown \wr \triangleleft \triangleright \infty \bot \top</span>
|
||||
<span class="katex">\leftarrow \gets \rightarrow \to \nleftarrow \nrightarrow \leftrightarrow \nleftrightarrow \longleftarrow \longrightarrow \longleftrightarrow</span>
|
||||
<span class="katex">\uparrow \downarrow \updownarrow \Uparrow \Downarrow \Updownarrow \nearrow \searrow \swarrow \nwarrow</span>
|
||||
<span class="katex">\rightharpoonup \rightharpoondown \leftharpoonup \leftharpoondown \upharpoonleft \upharpoonright \downharpoonleft \downharpoonright \rightleftharpoons \leftrightharpoons</span>
|
||||
<span class="katex">\curvearrowleft \circlearrowleft \Lsh \upuparrows \rightrightarrows \rightleftarrows \Rrightarrow \rightarrowtail \looparrowright</span>
|
||||
<span class="katex">\curvearrowright \circlearrowright \Rsh \downdownarrows \leftleftarrows \leftrightarrows \Lleftarrow \leftarrowtail \looparrowleft</span>
|
||||
<span class="katex">\mapsto \longmapsto \hookrightarrow \hookleftarrow \multimap \leftrightsquigarrow \rightsquigarrow</span>
|
||||
<span class="katex">\Diamond \Box \triangle \angle \perp \mid \nmid \| 45^\circ</span>
|
||||
<span class="katex">
|
||||
\sim \approx \simeq \cong \dot= \overset{\underset{\mathrm{def}}{}}{=}</span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<span class="katex"></span>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min.css">
|
||||
<script src="//cdnjs.cloudflare.com/ajax/libs/KaTeX/0.3.0/katex.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$(".katex").each(function(){
|
||||
var tex = $(this);
|
||||
katex.render(tex.text(), tex[0]);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
221
public/editormd/tests/marked-@at-test.html
Normal file
221
public/editormd/tests/marked-@at-test.html
Normal file
@@ -0,0 +1,221 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>Marked @ Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../dist/css/editormd.min.css" />
|
||||
<style>
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,
|
||||
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {display: block;}
|
||||
audio, canvas, video {display: inline-block;}
|
||||
|
||||
body, button, input, select, textarea {font:12px/1.5 Tahoma, "Hiragino Sans GB", "Microsoft Yahei", Arial;}
|
||||
body{font-size:12px;color:#666;background:#fff url(../images/) no-repeat left top;}
|
||||
|
||||
body{font-size:14px;color:#444;font-family:"微软雅黑",Arial;background:#fff;padding: 15px;}
|
||||
|
||||
a{color:blue;text-decoration: none;}
|
||||
a:hover{text-decoration: underline;}
|
||||
|
||||
.clear{zoom:1;}
|
||||
.clear:after{content:"";height:0;visibility:hidden;clear:both;display:block;}
|
||||
|
||||
img{border:none;vertical-align: middle;}
|
||||
|
||||
ul, ol {margin-left: 18px;}
|
||||
|
||||
table {
|
||||
margin: 10px 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table th, table td {
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding:8px;border-radius:3px;border:1px solid #ddd;background:#f6f6f6;margin: 15px 0;display: inline-block;
|
||||
}
|
||||
|
||||
pre code {
|
||||
|
||||
}
|
||||
|
||||
.editormd-logo,
|
||||
.editormd-logo-4x {
|
||||
font-family: editormd-logo;
|
||||
speak: none;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
font-size: inherit;
|
||||
line-height: 1;
|
||||
display: inline-block;
|
||||
text-rendering: auto;
|
||||
vertical-align: inherit;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.editormd-logo:before,
|
||||
.editormd-logo-4x:before {
|
||||
content: "\e1987";
|
||||
}
|
||||
.editormd-logo-4x {
|
||||
font-size:4em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<pre id="test"> ~~@mentions~~, #refs @tylerlong `inline code @tylerlong`, [links](), **formatting**, and <del>tags</del> supported @pandao;
|
||||
list syntax required (any unordered or ordered list supported) @pandao;
|
||||
this is @pandao a complete item @pandao;
|
||||
link [@pandao](https://github.com/pandao "@pandao") @
|
||||
link [@pandao](https://github.com/pandao "@pandao")
|
||||
this is an incomplete item **@pandao**;
|
||||
*@pandao* this is an incomplete item ___@pandao___;
|
||||
# Github: @pandao
|
||||
## Github: @pandao
|
||||
### Github: @tylerlong
|
||||
#### Github: @tylerlong
|
||||
##### Github: @tylerlong
|
||||
###### Github: @tylerlong
|
||||
|
||||
- dafssdfsdaf@chjj dfsdfsdf
|
||||
- dafssdfsdaf@chjj dfsdfsdf
|
||||
- dafssdfsdaf@chjj dfsdfsdf
|
||||
- dafss@pandao dfsdaf@chjj dfsdfsdf
|
||||
- dafssd: @pandao fsdaf@chjj dfsdfsdf @codemirror @pandao
|
||||
+ dafssdfsdaf@chjj dfsdfsdf
|
||||
+ dafss@pandaodfsdaf@chjj dfsdfsdf
|
||||
|
||||
|
||||
1. @chjj 第一行@pandao fsdaf@chjj dfsdfsdf :fa-save:: @pandao
|
||||
- dafssdfsdaf@chjj dfsdfsdf
|
||||
- dafss@pandao dfsdaf@chjj dfsdfsdf
|
||||
2. @chjj 第二行@pandao fsdaf@chjj dfsdfsdf @codemirror @pandao
|
||||
3. 第三行@pandao fsdaf@chjj dfsdfsdf :fa-save:: @pandao
|
||||
|
||||
> Blockquotes @pandao
|
||||
|
||||
> dd@pandao引用文本(Blockquotes @pandao)fdasfad @_pandao fdasfad @xxx454xxx fdasfad @xx_x454xxx454
|
||||
|
||||
|@pandao First Header | Second@pandao Header@pandao |
|
||||
| ------------- | ------------- |
|
||||
| Content@pandao Cell | @pandao Content Cell @pandao|
|
||||
| Con@pandao tent Cell@pandao | Content@pan-dao Cell dfsdfsdf @pan_dao |
|
||||
|
||||
dsfdf@pandao fasdfsdfsfddffd@pandao
|
||||
|
||||
dfasfasdfasdf:bangbang:
|
||||
|
||||
This is an H1 @pandao
|
||||
=============
|
||||
|
||||
This @pandao an H2 @pandao
|
||||
-------------
|
||||
</pre>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<script src="../lib/marked.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
var markedRenderer = new marked.Renderer();
|
||||
var markdownToC = markdownToC || [];
|
||||
|
||||
console.log("markedRenderer =>", markedRenderer);
|
||||
|
||||
var atReg = /@(\w+)/g;
|
||||
|
||||
markedRenderer.at = function(text) {
|
||||
|
||||
if (atReg.test(text))
|
||||
{
|
||||
text = text.replace(atReg, function($1, $2){
|
||||
console.log($1, $2);
|
||||
return "<a href=\"https://github.com/" + $2 + "\">" + $1 + "</a>";
|
||||
});
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
markedRenderer.link = function (href,title,text){
|
||||
console.log("link =>", href,title,text);
|
||||
|
||||
if(this.options.sanitize) {
|
||||
try{
|
||||
var prot=decodeURIComponent(unescape(href)).replace(/[^\w:]/g,"").toLowerCase()
|
||||
}catch(e){
|
||||
return""
|
||||
}
|
||||
|
||||
if(prot.indexOf("javascript:")===0){
|
||||
return""
|
||||
}
|
||||
}
|
||||
|
||||
var out='<a href="'+href+'"';
|
||||
|
||||
if (atReg.test(title) || atReg.test(text))
|
||||
{
|
||||
return out + " title=\"" + title.replace(/@/g, "@") + "\">" + text.replace(/@/g, "@") + "</a>";
|
||||
}
|
||||
|
||||
if(title) {
|
||||
out+=' title="'+title+'"'
|
||||
}
|
||||
|
||||
out+=">"+text+"</a>";
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
markedRenderer.paragraph = function(text) {
|
||||
console.log("paragraph =>", text, atReg.test(text));
|
||||
return "<p>" + this.at(text) + "</p>\n";
|
||||
};
|
||||
|
||||
markedRenderer.heading = function (text,level,raw){
|
||||
return"<h"+level+' id="'+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+'">'+this.at(text)+"</h"+level+">\n"
|
||||
};
|
||||
|
||||
markedRenderer.listitem = function (text){
|
||||
return "<li>" + this.at(text) + "</li>\n";
|
||||
};
|
||||
|
||||
markedRenderer.tablecell = function (content,flags){
|
||||
console.log(content);
|
||||
var type=flags.header?"th":"td";
|
||||
var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";
|
||||
return tag+this.at(content)+"</"+type+">\n";
|
||||
}
|
||||
|
||||
marked.setOptions({
|
||||
renderer : markedRenderer,
|
||||
gfm : true,
|
||||
tables : true,
|
||||
breaks : true,
|
||||
pedantic : false,
|
||||
smartLists : true,
|
||||
smartypants : true
|
||||
});
|
||||
|
||||
var markdown = $("#test").html();
|
||||
|
||||
var md = marked(markdown);
|
||||
//console.log(markdown);
|
||||
|
||||
$("body").append(md);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
231
public/editormd/tests/marked-emoji-test.html
Normal file
231
public/editormd/tests/marked-emoji-test.html
Normal file
@@ -0,0 +1,231 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>Marked Emoji Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../dist/css/editormd.min.css" />
|
||||
<style>
|
||||
body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,code,form,fieldset,legend,input,textarea,p,blockquote,th,td,hr,button,
|
||||
article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section {
|
||||
margin:0;
|
||||
padding:0;
|
||||
}
|
||||
|
||||
article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section, summary {display: block;}
|
||||
audio, canvas, video {display: inline-block;}
|
||||
|
||||
body, button, input, select, textarea {font:12px/1.5 Tahoma, "Hiragino Sans GB", "Microsoft Yahei", Arial;}
|
||||
body{font-size:12px;color:#666;background:#fff url(../images/) no-repeat left top;}
|
||||
|
||||
body{font-size:14px;color:#444;font-family:"微软雅黑",Arial;background:#fff;padding: 15px;}
|
||||
|
||||
a{color:#444;text-decoration: none;}
|
||||
a:hover{color:#065BC2;text-decoration: none;}
|
||||
|
||||
.clear{zoom:1;}
|
||||
.clear:after{content:"";height:0;visibility:hidden;clear:both;display:block;}
|
||||
|
||||
img{border:none;vertical-align: middle;}
|
||||
|
||||
ul, ol {margin-left: 18px;}
|
||||
|
||||
table {
|
||||
margin: 10px 0;
|
||||
border-collapse: collapse;
|
||||
}
|
||||
|
||||
table th, table td {
|
||||
padding: 5px 8px;
|
||||
border: 1px solid #ddd;
|
||||
}
|
||||
|
||||
pre {
|
||||
padding:8px;border-radius:3px;border:1px solid #ddd;background:#f6f6f6;margin: 15px 0;display: inline-block;
|
||||
}
|
||||
|
||||
pre code {
|
||||
|
||||
}
|
||||
|
||||
.editormd-logo,
|
||||
.editormd-logo-4x {
|
||||
font-family: editormd-logo;
|
||||
speak: none;
|
||||
font-style: normal;
|
||||
font-weight: 400;
|
||||
font-variant: normal;
|
||||
text-transform: none;
|
||||
font-size: inherit;
|
||||
line-height: 1;
|
||||
display: inline-block;
|
||||
text-rendering: auto;
|
||||
vertical-align: inherit;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
-moz-osx-font-smoothing: grayscale;
|
||||
}
|
||||
.editormd-logo:before,
|
||||
.editormd-logo-4x:before {
|
||||
content: "\e1987";
|
||||
}
|
||||
.editormd-logo-4x {
|
||||
font-size:4em;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<i class="editormd-logo editormd-logo-4x"></i><br/>
|
||||
<pre id="md">> Blockquotes
|
||||
dasfsadfasdf:fa-edit: :warning: :smiley:dsafsdfsad\:fdsfdf\:f dfdf: :fa-save::fa-star: :fa-truck:
|
||||
**fdfasd:smiley:dsfsdfsfd** ~~fsdfds:smiley:dfsdfsdf :fa-info:~~
|
||||
*dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf*
|
||||
___Emphasis :fa-gear: Italic:smiley:___ __Emphasis:smiley:__
|
||||
# H1 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf
|
||||
## H2 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf
|
||||
### H3 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf:fa-edit: fdsfsdf:fa-save:dsfsdf
|
||||
#### H4 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf:fa-edit: fdsfsdf:fa-save:dsfsdf
|
||||
##### H5 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf:fa-edit: fdsfsdf:fa-save:dsfsdf
|
||||
###### H6 dsfdfsfd:smiley:dsfsfdsfd:smiley:dsfdf:fa-edit: fdsfsdf:fa-star:dsfsdf
|
||||
[:smiley:](http://www.emoji-cheat-sheet.com/ "link + emoji") link + emoji
|
||||
- dafssdfsdaf:smiley:dfsdfsdf
|
||||
- dafssdfsdaf:smiley:dfsdfsdf
|
||||
- dafssdfsdaf:smiley:dfsdfsdf
|
||||
- dafss:fa-truck:dfsdaf:smiley:dfsdfsdf
|
||||
- dafssd: :fa-truck:fsdaf:smiley:dfsdfsdf :fa-star:: :fa-truck:
|
||||
+ dafssdfsdaf:smiley:dfsdfsdf
|
||||
+ dafss:fa-truck:dfsdaf:smiley:dfsdfsdf
|
||||
|
||||
|
||||
1. :smiley:第一行:fa-truck:fsdaf:smiley:dfsdfsdf :fa-save:: :fa-truck:
|
||||
- dafssdfsdaf:smiley:dfsdfsdf
|
||||
- dafss:fa-truck:dfsdaf:smiley:dfsdfsdf
|
||||
2. :smiley:第二行:fa-truck:fsdaf:smiley:dfsdfsdf :fa-star:: :fa-truck:
|
||||
3. 第三行:fa-truck:fsdaf:smiley:dfsdfsdf :fa-save:: :fa-truck:
|
||||
|
||||
> Blockquotes
|
||||
|
||||
> dd:smiley:引用文本(Blockquotes:smiley:)fdasfad :fa-star:: dfd :fa-truck:
|
||||
|
||||
|:100: First Header | Second:smiley: Header:smiley: |
|
||||
| ------------- | ------------- |
|
||||
| Content:fa-truck: Cell | :smiley:Content Cell :smiley: |
|
||||
| Con:fa-truck:tent Cell:bangbang: | Content Cell dfsdfsdf :fa-star: :dfdf :fa-truck: |
|
||||
|
||||
:fa-heart:fasdfsdfsfddffd:editormd-logo: :editormd-logo: :editormd-logo-4x:
|
||||
|
||||
dfasfasdfasdf:bangbang:
|
||||
|
||||
This is an H1 :editormd-logo-4x:
|
||||
=============
|
||||
|
||||
This :fa-save:: :fa-truck:is an H2 :100:
|
||||
-------------
|
||||
</pre>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<script src="../lib/marked.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
var markedRenderer = new marked.Renderer();
|
||||
var markdownToC = markdownToC || [];
|
||||
var emojiReg = /:([\-\w]+):/g;
|
||||
var faIconReg = /:fa-([\w]+):/g;
|
||||
var editormdLogoReg = /:(editormd-logo\s?-?(\w+)?):/g;
|
||||
|
||||
console.log("markedRenderer =>", markedRenderer);
|
||||
|
||||
markedRenderer.emoji = function(text) {
|
||||
console.log("emoji.text =>", text);
|
||||
var matchs = text.match(emojiReg);
|
||||
console.log(matchs);
|
||||
|
||||
if ( matchs)
|
||||
{
|
||||
for (var i = 0, len = matchs.length; i < len; i++)
|
||||
{
|
||||
text = text.replace(new RegExp(matchs[i]), function($1, $2){
|
||||
var faMatchs = $1.match(faIconReg);
|
||||
//console.log("famatchs =>", faMatchs);
|
||||
var name = $1.replace(/:/g, ""); // http://www.emoji-cheat-sheet.com/graphics/emojis/smile.png
|
||||
console.log("replace =>", name, $1, $2);
|
||||
|
||||
if (faMatchs)
|
||||
{
|
||||
for (var fa = 0, len1 = faMatchs.length; fa < len1; fa++)
|
||||
{
|
||||
return "<i class=\"fa "+faMatchs[fa].replace(/:/g, "")+"\"></i>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var emdlogoMathcs = $1.match(editormdLogoReg);
|
||||
|
||||
if (emdlogoMathcs)
|
||||
{
|
||||
for (var x = 0, len2 = emdlogoMathcs.length; x < len2; x++)
|
||||
{
|
||||
return "<i class=\""+emdlogoMathcs[x].replace(/:/g, "")+"\"></i>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "<img src=\"http://www.emoji-cheat-sheet.com/graphics/emojis/"+name+".png\" />";
|
||||
}
|
||||
}
|
||||
//return (faIconReg.test($1)) ? "<i class=\"fa "+name+"\"></i>" : (editormdLogoReg.test($1)) ? "<i class=\""+name+"\"></i>" : "<img src=\"http://www.emoji-cheat-sheet.com/graphics/emojis/"+name+".png\" />";
|
||||
});
|
||||
}
|
||||
|
||||
console.log(emojiReg.exec(text));
|
||||
console.log(text, emojiReg.test(text), faIconReg.test(text));
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
markedRenderer.blockquote = function (quote){
|
||||
console.log("quote =>", quote);
|
||||
return "<blockquote>\n"+quote+"</blockquote>\n";
|
||||
};
|
||||
|
||||
markedRenderer.tablecell = function (content,flags){
|
||||
console.log(content);
|
||||
var type=flags.header?"th":"td";
|
||||
var tag=flags.align?"<"+type+' style="text-align:'+flags.align+'">':"<"+type+">";
|
||||
return tag+this.emoji(content)+"</"+type+">\n";
|
||||
}
|
||||
|
||||
markedRenderer.heading = function (text,level,raw){
|
||||
return"<h"+level+' id="'+this.options.headerPrefix+raw.toLowerCase().replace(/[^\w]+/g,"-")+'">'+this.emoji(text)+"</h"+level+">\n"
|
||||
};
|
||||
|
||||
markedRenderer.listitem = function (text){
|
||||
return "<li>" + this.emoji(text) + "</li>\n";
|
||||
};
|
||||
|
||||
markedRenderer.paragraph = function(text) {
|
||||
|
||||
console.log("paragraph =>", text, text.match(emojiReg));
|
||||
return "<p>" + this.emoji(text) + "</p>\n";
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
renderer : markedRenderer,
|
||||
gfm : true,
|
||||
tables : true,
|
||||
breaks : true,
|
||||
pedantic : false,
|
||||
smartLists : true,
|
||||
smartypants : true
|
||||
});
|
||||
|
||||
var mdsrc = $("#md").html();
|
||||
var md = marked(mdsrc);
|
||||
//console.log(mdsrc);
|
||||
|
||||
$("body").append(md);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
138
public/editormd/tests/marked-heading-link-test.html
Normal file
138
public/editormd/tests/marked-heading-link-test.html
Normal file
@@ -0,0 +1,138 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>Marked heading link Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../examples/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<script src="../lib/marked.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
var linkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
|
||||
var linkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
|
||||
|
||||
var testLink = "<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"Markdown Basics\">Markdown Basics</a> ";
|
||||
var testLink2 = "<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"Xdfsdf\">Xdfsdf</a> ";
|
||||
var testLink3 = "<a href=\"\" title=\"\"></a> ";
|
||||
var texts = (testLink + testLink2 + testLink3).split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
|
||||
|
||||
console.log(texts);
|
||||
|
||||
for (var i = 0, len = texts.length; i < len; i++)
|
||||
{
|
||||
if((i+1) % 3 == 0) console.log(texts[i]);
|
||||
}
|
||||
|
||||
(testLink + testLink2).replace(linkTextReg, function(){
|
||||
//console.log($1, $2);
|
||||
//console.log("linkText =>", $3);
|
||||
console.log(arguments);
|
||||
});
|
||||
|
||||
testLink.replace(linkTextReg, function($1, $2, $3){
|
||||
console.log($1, $2, $3);
|
||||
});
|
||||
|
||||
console.log(linkReg.test(" <a name=\"dddd\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
|
||||
|
||||
console.log(linkReg.test("<a name=\"dddd\" href=\"http://daringfireball.com/projects/markdown/basics\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
|
||||
|
||||
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\" class=\"link\" style=\"color:red;\">Markdown Basics</a> "));
|
||||
|
||||
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"dddd\"><span>Markdown Basics</span></a> "));
|
||||
|
||||
console.log(linkReg.test("<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\"><span class=\"active\">Markdown Basics</span></a> "));
|
||||
console.log(linkReg.test("<a href=\"http://www.fdasfasdfsdaf.com/projects/markdown/basics\" title=\"dddd\"><a href=\"#ddd\" class=\"active\">Markdown Basics</a></a> "));
|
||||
console.log(linkReg.test("afdsfasfsadf<a href=\"http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526\" title=\"dddd\"><a href=\"#ddd\" class=\"active\">Markdown Basics</a></a> fdasfasdfadsfsfd <a href=\"http://daringfireball.net/projects/markdown/basics\" title=\"dddd\"><span>Markdown Basics</span></a>"));
|
||||
|
||||
$(function() {
|
||||
var markedRenderer = new marked.Renderer();
|
||||
var markdownToC = markdownToC || [];
|
||||
|
||||
markedRenderer.heading = function(text, level, raw) {
|
||||
|
||||
var linkText = text;
|
||||
var hasLinkReg = /\s*\<a\s*href\=\"(.*)\"\s*([^\>]*)\>(.*)\<\/a\>\s*/;
|
||||
var getLinkTextReg = /\s*\<a\s*([^\>]+)\>([^\>]*)\<\/a\>\s*/g;
|
||||
|
||||
if (hasLinkReg) {
|
||||
var tempText = [];
|
||||
text = text.split(/\<a\s*([^\>]+)\>([^\>]*)\<\/a\>/);
|
||||
|
||||
console.log(text);
|
||||
|
||||
for (var i = 0, len = text.length; i < len; i++)
|
||||
{
|
||||
if((i+1) % 3 == 0) tempText.push(text[i]);
|
||||
}
|
||||
|
||||
text = tempText.join(" ");
|
||||
}
|
||||
|
||||
var escapedText = text.toLowerCase().replace(/[^\w]+/g, "-");
|
||||
var toc = {
|
||||
text : text,
|
||||
level : level,
|
||||
slug : escapedText
|
||||
};
|
||||
|
||||
console.log("text =>", text);
|
||||
|
||||
var isChinese = /^[\u4e00-\u9fa5]+$/.test(text);
|
||||
var id = (isChinese) ? escape(text).replace(/\%/g, "") : text.toLowerCase().replace(/[^\w]+/g, "-");
|
||||
|
||||
markdownToC.push(toc);
|
||||
|
||||
console.log("toc =>", toc);
|
||||
|
||||
var headingHTML = "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">";
|
||||
|
||||
/*return "<h" + level + " id=\"h"+ level + "-" + this.options.headerPrefix + id +"\">" +
|
||||
"<a href=\"#" + text + "\" name=\"" + text + "\" class=\"anchor\"></a>" +
|
||||
"<span class=\"header-link\"></span>" + text + "</h" + level + ">";*/
|
||||
|
||||
var anchor = "<a name=\"" + text + "\" class=\"anchor\"></a>";
|
||||
|
||||
headingHTML += anchor;
|
||||
|
||||
headingHTML += "<span class=\"header-link\"></span>";
|
||||
|
||||
headingHTML += (hasLinkReg) ? linkText : text;
|
||||
|
||||
headingHTML += "</h" + level + ">";
|
||||
|
||||
return headingHTML;
|
||||
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
renderer : markedRenderer,
|
||||
gfm : true,
|
||||
tables : true,
|
||||
breaks : true,
|
||||
pedantic : false,
|
||||
smartLists : true,
|
||||
smartypants : true
|
||||
});
|
||||
|
||||
var md = marked("## [Markdown Basics](http://daringfireball.net/projects/markdown/basics \"Markdown Basics\")");
|
||||
console.log(md);
|
||||
|
||||
var md2 = marked("## fdasfsd [Markdown Basics](http://daringfireball.net/projects/markdown/basics \"Markdown Basics\") xxx [Editor.md](http://daringfireball.net/projects/markdown/basics \"Editor.md\") fadsfasdfasdf");
|
||||
console.log(md2);
|
||||
|
||||
var md3 = marked("### fdasfsd中文链接 [中文链接](http://daringfireball.net/projects/markdown/basics \"中文链接\") xxx 中文链接 [Editor.md 在线Markdown编辑器](http://daringfireball.net/projects/markdown/basics \"Editor.md 在线Markdown编辑器\") fadsfasdfasdf中文链接");
|
||||
console.log(md3);
|
||||
|
||||
var md4 = marked("#### fdasfsd [Markdown Basics](http://daringfireball.net/projects/markdown/basics?xx=ddd&fddf&temp=265656565665656526 \"Markdown Basics\") xxx [Editor.md](http://www.ipandao.com/#xxxxx \"Editor.md\") fadsfasdfasdf");
|
||||
console.log(md4);
|
||||
|
||||
$("body").append(md).append(md2).append(md3).append(md4);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
61
public/editormd/tests/marked-todo-list-test.html
Normal file
61
public/editormd/tests/marked-todo-list-test.html
Normal file
@@ -0,0 +1,61 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh">
|
||||
<head>
|
||||
<title>Marked Emoji Test</title>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="description" content="" />
|
||||
<meta name="keywords" content="" />
|
||||
<link rel="stylesheet" href="../examples/css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
<script src="../examples/js/jquery.min.js"></script>
|
||||
<script src="../lib/marked.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
|
||||
$(function() {
|
||||
var markedRenderer = new marked.Renderer();
|
||||
var markdownToC = markdownToC || [];
|
||||
|
||||
console.log("markedRenderer =>", markedRenderer);
|
||||
|
||||
markedRenderer.listitem = function(text) {
|
||||
if (/^\s*\[[x\s]\]\s*/.test(text))
|
||||
{
|
||||
console.log("is todo list =>", text);
|
||||
text = text.replace(/^\s*\[\s\]\s*/, '<input type="checkbox" class="task-list-item-checkbox"> ')
|
||||
.replace(/^\s*\[x\]\s*/, '<input type="checkbox" class="task-list-item-checkbox" checked disabled /> ');
|
||||
|
||||
return '<li style="list-style: none">' + text + '</li>';
|
||||
}
|
||||
else
|
||||
{
|
||||
return '<li>' + text + '</li>';
|
||||
}
|
||||
};
|
||||
|
||||
marked.setOptions({
|
||||
renderer : markedRenderer,
|
||||
gfm : true,
|
||||
tables : true,
|
||||
breaks : true,
|
||||
pedantic : false,
|
||||
smartLists : true,
|
||||
smartypants : true
|
||||
});
|
||||
|
||||
var todoListMarkdown = [
|
||||
"- [x] @mentions, #refs, [links](), **formatting**, and <del>tags</del> supported;",
|
||||
"- [x] list syntax required (any unordered or ordered list supported);",
|
||||
"- [x] this is a complete item;",
|
||||
"- [ ] this is an incomplete item;",
|
||||
"- [ ] this is an incomplete item;"
|
||||
].join("\n");
|
||||
|
||||
var md = marked(todoListMarkdown);
|
||||
console.log(md);
|
||||
|
||||
$("body").append(md);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
264
public/editormd/tests/qunit/qunit-1.16.0.css
Normal file
264
public/editormd/tests/qunit/qunit-1.16.0.css
Normal file
@@ -0,0 +1,264 @@
|
||||
/*!
|
||||
* QUnit 1.16.0
|
||||
* http://qunitjs.com/
|
||||
*
|
||||
* Copyright 2006, 2014 jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*
|
||||
* Date: 2014-12-03T16:32Z
|
||||
*/
|
||||
|
||||
/** Font Family and Sizes */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult {
|
||||
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; }
|
||||
#qunit-tests { font-size: smaller; }
|
||||
|
||||
|
||||
/** Resets */
|
||||
|
||||
#qunit-tests, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult, #qunit-modulefilter {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
|
||||
/** Header */
|
||||
|
||||
#qunit-header {
|
||||
padding: 0.5em 0 0.5em 1em;
|
||||
|
||||
color: #8699A4;
|
||||
background-color: #0D3349;
|
||||
|
||||
font-size: 1.5em;
|
||||
line-height: 1em;
|
||||
font-weight: 400;
|
||||
|
||||
border-radius: 5px 5px 0 0;
|
||||
}
|
||||
|
||||
#qunit-header a {
|
||||
text-decoration: none;
|
||||
color: #C2CCD1;
|
||||
}
|
||||
|
||||
#qunit-header a:hover,
|
||||
#qunit-header a:focus {
|
||||
color: #FFF;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar label {
|
||||
display: inline-block;
|
||||
padding: 0 0.5em 0 0.1em;
|
||||
}
|
||||
|
||||
#qunit-banner {
|
||||
height: 5px;
|
||||
}
|
||||
|
||||
#qunit-testrunner-toolbar {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
color: #5E740B;
|
||||
background-color: #EEE;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
#qunit-userAgent {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
background-color: #2B81AF;
|
||||
color: #FFF;
|
||||
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
|
||||
}
|
||||
|
||||
#qunit-modulefilter-container {
|
||||
float: right;
|
||||
}
|
||||
|
||||
/** Tests: Pass/Fail */
|
||||
|
||||
#qunit-tests {
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests li {
|
||||
padding: 0.4em 1em 0.4em 1em;
|
||||
border-bottom: 1px solid #FFF;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
#qunit-tests > li {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li.pass, #qunit-tests li.running, #qunit-tests li.fail {
|
||||
display: list-item;
|
||||
}
|
||||
|
||||
#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests li strong {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
#qunit-tests li.skipped strong {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
#qunit-tests li a {
|
||||
padding: 0.5em;
|
||||
color: #C2CCD1;
|
||||
text-decoration: none;
|
||||
}
|
||||
#qunit-tests li a:hover,
|
||||
#qunit-tests li a:focus {
|
||||
color: #000;
|
||||
}
|
||||
|
||||
#qunit-tests li .runtime {
|
||||
float: right;
|
||||
font-size: smaller;
|
||||
}
|
||||
|
||||
.qunit-assert-list {
|
||||
margin-top: 0.5em;
|
||||
padding: 0.5em;
|
||||
|
||||
background-color: #FFF;
|
||||
|
||||
border-radius: 5px;
|
||||
}
|
||||
|
||||
.qunit-collapsed {
|
||||
display: none;
|
||||
}
|
||||
|
||||
#qunit-tests table {
|
||||
border-collapse: collapse;
|
||||
margin-top: 0.2em;
|
||||
}
|
||||
|
||||
#qunit-tests th {
|
||||
text-align: right;
|
||||
vertical-align: top;
|
||||
padding: 0 0.5em 0 0;
|
||||
}
|
||||
|
||||
#qunit-tests td {
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
#qunit-tests pre {
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
#qunit-tests del {
|
||||
background-color: #E0F2BE;
|
||||
color: #374E0C;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
#qunit-tests ins {
|
||||
background-color: #FFCACA;
|
||||
color: #500;
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
/*** Test Counts */
|
||||
|
||||
#qunit-tests b.counts { color: #000; }
|
||||
#qunit-tests b.passed { color: #5E740B; }
|
||||
#qunit-tests b.failed { color: #710909; }
|
||||
|
||||
#qunit-tests li li {
|
||||
padding: 5px;
|
||||
background-color: #FFF;
|
||||
border-bottom: none;
|
||||
list-style-position: inside;
|
||||
}
|
||||
|
||||
/*** Passing Styles */
|
||||
|
||||
#qunit-tests li li.pass {
|
||||
color: #3C510C;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #C6E746;
|
||||
}
|
||||
|
||||
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
|
||||
#qunit-tests .pass .test-name { color: #366097; }
|
||||
|
||||
#qunit-tests .pass .test-actual,
|
||||
#qunit-tests .pass .test-expected { color: #999; }
|
||||
|
||||
#qunit-banner.qunit-pass { background-color: #C6E746; }
|
||||
|
||||
/*** Failing Styles */
|
||||
|
||||
#qunit-tests li li.fail {
|
||||
color: #710909;
|
||||
background-color: #FFF;
|
||||
border-left: 10px solid #EE5757;
|
||||
white-space: pre;
|
||||
}
|
||||
|
||||
#qunit-tests > li:last-child {
|
||||
border-radius: 0 0 5px 5px;
|
||||
}
|
||||
|
||||
#qunit-tests .fail { color: #000; background-color: #EE5757; }
|
||||
#qunit-tests .fail .test-name,
|
||||
#qunit-tests .fail .module-name { color: #000; }
|
||||
|
||||
#qunit-tests .fail .test-actual { color: #EE5757; }
|
||||
#qunit-tests .fail .test-expected { color: #008000; }
|
||||
|
||||
#qunit-banner.qunit-fail { background-color: #EE5757; }
|
||||
|
||||
/*** Skipped tests */
|
||||
|
||||
#qunit-tests .skipped {
|
||||
background-color: #EBECE9;
|
||||
}
|
||||
|
||||
#qunit-tests .qunit-skipped-label {
|
||||
background-color: #F4FF77;
|
||||
display: inline-block;
|
||||
font-style: normal;
|
||||
color: #366097;
|
||||
line-height: 1.8em;
|
||||
padding: 0 0.5em;
|
||||
margin: -0.4em 0.4em -0.4em 0;
|
||||
}
|
||||
|
||||
/** Result */
|
||||
|
||||
#qunit-testresult {
|
||||
padding: 0.5em 1em 0.5em 1em;
|
||||
|
||||
color: #2B81AF;
|
||||
background-color: #D2E0E6;
|
||||
|
||||
border-bottom: 1px solid #FFF;
|
||||
}
|
||||
#qunit-testresult .module-name {
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
/** Fixture */
|
||||
|
||||
#qunit-fixture {
|
||||
position: absolute;
|
||||
top: -10000px;
|
||||
left: -10000px;
|
||||
width: 1000px;
|
||||
height: 1000px;
|
||||
}
|
||||
2819
public/editormd/tests/qunit/qunit-1.16.0.js
Normal file
2819
public/editormd/tests/qunit/qunit-1.16.0.js
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user