From b0b2f1d4a369fa04479d9048250a74b798f54ae8 Mon Sep 17 00:00:00 2001 From: Josh Schonstal Date: Wed, 22 Jun 2016 09:36:09 -0700 Subject: [PATCH] Allow user to configure marked options --- README.md | 1 + src/js/simplemde.js | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 03793c9..8e46969 100644 --- a/README.md +++ b/README.md @@ -96,6 +96,7 @@ simplemde.value("This text will appear in the editor"); - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews. - **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). + - **markedOptions**: Set default marked markdown renderer default [options](https://github.com/chjj/marked#options-1). `singleLineBreaks` and `codeSyntaxHighlighting` options below will take precedence. - **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:
``
`` - **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts). diff --git a/src/js/simplemde.js b/src/js/simplemde.js index 016d693..a110ef4 100644 --- a/src/js/simplemde.js +++ b/src/js/simplemde.js @@ -1392,8 +1392,12 @@ function SimpleMDE(options) { SimpleMDE.prototype.markdown = function(text) { if(marked) { // Initialize - var markedOptions = {}; - + var markedOptions; + if(this.options && this.options.renderingConfig && this.options.renderingConfig.markedOptions) { + markedOptions = this.options.renderingConfig.markedOptions; + } else { + markedOptions = {}; + } // Update options if(this.options && this.options.renderingConfig && this.options.renderingConfig.singleLineBreaks === false) {