pull/437/merge
wisetwo 8 years ago committed by GitHub
commit 12607ff4a4

@ -328,4 +328,4 @@ simplemde.clearAutosavedValue(); // no returned value
## 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).
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": {
"codemirror": "*",
"codemirror-spell-checker": "*",
"marked": "*"
"marked": "*",
"remarkable": "^1.6.2"
},
"devDependencies": {
"browserify": "*",

@ -11,7 +11,8 @@ require("codemirror/addon/selection/mark-selection.js");
require("codemirror/mode/gfm/gfm.js");
require("codemirror/mode/xml/xml.js");
var CodeMirrorSpellChecker = require("codemirror-spell-checker");
var marked = require("marked");
//var marked = require("marked");
var Remarkable = require("remarkable");
// Some variables
@ -1390,7 +1391,7 @@ function SimpleMDE(options) {
* Default markdown render.
*/
SimpleMDE.prototype.markdown = function(text) {
if(marked) {
/*if(marked) {
// Initialize
var markedOptions = {};
@ -1415,7 +1416,30 @@ SimpleMDE.prototype.markdown = function(text) {
// Return
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);
}
};
/**
@ -2025,4 +2049,4 @@ SimpleMDE.prototype.toTextArea = function() {
}
};
module.exports = SimpleMDE;
module.exports = SimpleMDE;

Loading…
Cancel
Save