From 6b010b1fe7c0e7045ee8fd08b57a18fec0f31f19 Mon Sep 17 00:00:00 2001 From: Brecht Carlier Date: Thu, 15 Dec 2016 11:16:36 +0100 Subject: [PATCH 1/2] Added support for the sanitize option of 'marked' --- src/js/simplemde.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 016d693..bf1b016 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1401,6 +1401,12 @@ SimpleMDE.prototype.markdown = function(text) { } else { markedOptions.breaks = true; } + + if(this.options && this.options.renderingConfig && this.options.renderingConfig.sanitize === true) { + markedOptions.sanitize = true; + } else { + markedOptions.sanitize = false; + } if(this.options && this.options.renderingConfig && this.options.renderingConfig.codeSyntaxHighlighting === true && window.hljs) { markedOptions.highlight = function(code) { @@ -2025,4 +2031,4 @@ SimpleMDE.prototype.toTextArea = function() { } }; -module.exports = SimpleMDE; \ No newline at end of file +module.exports = SimpleMDE; From 31d30dbec3fb2f78bab5c4caada123d319cae1be Mon Sep 17 00:00:00 2001 From: Brecht Carlier Date: Thu, 15 Dec 2016 11:20:39 +0100 Subject: [PATCH 2/2] Updated docs for sanitize option --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 03793c9..7c4781b 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ simplemde.value("This text will appear in the editor"); - **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`. - **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`. + - **sanitize**: If set to `true`, enable sanitizing on the preview. e.g. '<br/>' will be render as text instead of a line-break - **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:
``
`` - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). - **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar. @@ -152,6 +153,7 @@ var simplemde = new SimpleMDE({ promptURLs: true, renderingConfig: { singleLineBreaks: false, + sanitize: true, codeSyntaxHighlighting: true, }, shortcuts: {