mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2025-09-24 16:40:55 -06:00
Merge a23fd3b40afc6a2fd607b7a67aecae8411a89a39 into 6abda7ab68cc20f4aca870eb243747951b90ab04
This commit is contained in:
commit
12607ff4a4
@ -328,4 +328,4 @@ simplemde.clearAutosavedValue(); // no returned value
|
|||||||
## How it works
|
## How it works
|
||||||
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
|
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
|
||||||
|
|
||||||
CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GFM.
|
CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Remarkable](https://github.com/jonschlinkert/remarkable) using GFM, but with HTML disabled to prevent xss content, which is different from [marked](https://github.com/chjj/marked).
|
||||||
|
@ -23,7 +23,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"codemirror": "*",
|
"codemirror": "*",
|
||||||
"codemirror-spell-checker": "*",
|
"codemirror-spell-checker": "*",
|
||||||
"marked": "*"
|
"marked": "*",
|
||||||
|
"remarkable": "^1.6.2"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"browserify": "*",
|
"browserify": "*",
|
||||||
|
@ -11,7 +11,8 @@ require("codemirror/addon/selection/mark-selection.js");
|
|||||||
require("codemirror/mode/gfm/gfm.js");
|
require("codemirror/mode/gfm/gfm.js");
|
||||||
require("codemirror/mode/xml/xml.js");
|
require("codemirror/mode/xml/xml.js");
|
||||||
var CodeMirrorSpellChecker = require("codemirror-spell-checker");
|
var CodeMirrorSpellChecker = require("codemirror-spell-checker");
|
||||||
var marked = require("marked");
|
//var marked = require("marked");
|
||||||
|
var Remarkable = require("remarkable");
|
||||||
|
|
||||||
|
|
||||||
// Some variables
|
// Some variables
|
||||||
@ -1390,7 +1391,7 @@ function SimpleMDE(options) {
|
|||||||
* Default markdown render.
|
* Default markdown render.
|
||||||
*/
|
*/
|
||||||
SimpleMDE.prototype.markdown = function(text) {
|
SimpleMDE.prototype.markdown = function(text) {
|
||||||
if(marked) {
|
/*if(marked) {
|
||||||
// Initialize
|
// Initialize
|
||||||
var markedOptions = {};
|
var markedOptions = {};
|
||||||
|
|
||||||
@ -1415,7 +1416,30 @@ SimpleMDE.prototype.markdown = function(text) {
|
|||||||
|
|
||||||
// Return
|
// Return
|
||||||
return marked(text);
|
return marked(text);
|
||||||
}
|
}*/
|
||||||
|
if(Remarkable) {
|
||||||
|
var md = new Remarkable({
|
||||||
|
html: false,
|
||||||
|
xhtmlOut: true,
|
||||||
|
breaks: false,
|
||||||
|
highlight: function(str, lang) {
|
||||||
|
if(typeof window.hljs != undefined && lang && window.hljs.getLanguage(lang)) {
|
||||||
|
try {
|
||||||
|
return window.hljs.highlight(lang, str).value;
|
||||||
|
} catch(err) {
|
||||||
|
//continue
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return window.hljs.highlightAuto(str).value;
|
||||||
|
} catch(err) {
|
||||||
|
//continue
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return md.render(text);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user