mirror of
https://github.com/sparksuite/simplemde-markdown-editor.git
synced 2024-06-09 01:12:14 +02:00
New option: renderingConfig which includes syntax highlighting
This commit is contained in:
parent
a52a9a0098
commit
443a58cc28
|
@ -75,7 +75,9 @@ simplemde.value("This text will appear in the editor");
|
||||||
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
||||||
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
||||||
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
||||||
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
||||||
|
- **singleLineBreaks**: If set to `false`, disable parsing GFM single line breaks. Defaults to `true`.
|
||||||
|
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page. For example, include the script and the CSS files like: `<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>` and `<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
|
||||||
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
|
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`.
|
||||||
- **status**: If set to `false`, hide the status bar. Defaults to `true`.
|
- **status**: If set to `false`, hide the status bar. Defaults to `true`.
|
||||||
- Optionally, you can set an array of status bar elements to include, and in what order.
|
- Optionally, you can set an array of status bar elements to include, and in what order.
|
||||||
|
@ -111,7 +113,10 @@ var simplemde = new SimpleMDE({
|
||||||
|
|
||||||
return "Loading...";
|
return "Loading...";
|
||||||
}
|
}
|
||||||
singleLineBreaks: false,
|
renderingConfig: {
|
||||||
|
singleLineBreaks: false,
|
||||||
|
codeSyntaxHighlighting: true,
|
||||||
|
},
|
||||||
spellChecker: false,
|
spellChecker: false,
|
||||||
status: false,
|
status: false,
|
||||||
status: ['autosave', 'lines', 'words', 'cursor'], // Optional usage
|
status: ['autosave', 'lines', 'words', 'cursor'], // Optional usage
|
||||||
|
|
|
@ -827,13 +827,27 @@ SimpleMDE.toolbar = toolbar;
|
||||||
*/
|
*/
|
||||||
SimpleMDE.prototype.markdown = function(text) {
|
SimpleMDE.prototype.markdown = function(text) {
|
||||||
if(window.marked) {
|
if(window.marked) {
|
||||||
|
// Initialize
|
||||||
|
var markedOptions = {};
|
||||||
|
|
||||||
|
|
||||||
// Update options
|
// Update options
|
||||||
if(this.options && this.options.singleLineBreaks !== false) {
|
if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks !== false) {
|
||||||
marked.setOptions({
|
markedOptions.breaks = true;
|
||||||
breaks: true
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) {
|
||||||
|
markedOptions.highlight = function(code) {
|
||||||
|
return hljs.highlightAuto(code).value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Set options
|
||||||
|
marked.setOptions(markedOptions);
|
||||||
|
|
||||||
|
|
||||||
|
// Return
|
||||||
return marked(text);
|
return marked(text);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue