diff --git a/bower.json b/bower.json index d9fc779a..7a19e442 100644 --- a/bower.json +++ b/bower.json @@ -18,7 +18,7 @@ "requirejs-text": "~2.0.10", "bootstrap-tour": "~0.7.1", "ace": "4bbe5346f2ae5ad35c0c47defa244ab27aedd451", - "pagedown-ace": "https://github.com/benweet/pagedown-ace.git#72a27932f6f4f78e93a186aa2947d1f15c1cd7d5", + "pagedown-ace": "git@github.com:benweet/pagedown-ace.git#84d5e1b7ff233a1c8cafa9716e825228d275120c", "pagedown-extra": "git@github.com:jmcmanus/pagedown-extra.git#9c77f3ad718fec32935f092a560c0023355caf9a", "crel": "git@github.com:KoryNunn/crel.git#8dbda04b129fc0aec01a2a080d1cab26816e11c1", "waitForImages": "git@github.com:alexanderdickson/waitForImages.git#~1.4.2", @@ -30,7 +30,6 @@ }, "resolutions": { "jquery": "2.0.3", - "bootstrap": "v3.0.0", - "pagedown-extra": "05e56619f8fd74421575677c64eb895264f4c375" + "bootstrap": "v3.0.0" } } diff --git a/public/res/core.js b/public/res/core.js index d1f76694..19c0a248 100644 --- a/public/res/core.js +++ b/public/res/core.js @@ -524,6 +524,17 @@ define([ // Create the converter and the editor var converter = new Markdown.Converter(); + var options = { + _DoItalicsAndBold: function(text) { + // Restore original markdown implementation + text = text.replace(/(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\1/g, + "$2"); + text = text.replace(/(\*|_)(?=\S)(.+?)(?=\S)\1/g, + "$2"); + return text; + } + }; + converter.setOptions(options); function checkDocumentChanges() { var newDocumentContent = $editorElt.val(); diff --git a/public/res/extensions/markdownExtra.js b/public/res/extensions/markdownExtra.js index ff13c4c4..15ff49bf 100644 --- a/public/res/extensions/markdownExtra.js +++ b/public/res/extensions/markdownExtra.js @@ -23,6 +23,7 @@ define([ "strikethrough", "newlines", ], + intraword: true, highlighter: "prettify" }; @@ -40,6 +41,7 @@ define([ utils.setInputChecked("#input-markdownextra-smartypants", hasExtension("smartypants")); utils.setInputChecked("#input-markdownextra-strikethrough", hasExtension("strikethrough")); utils.setInputChecked("#input-markdownextra-newlines", hasExtension("newlines")); + utils.setInputChecked("#input-markdownextra-intraword", markdownExtra.config.intraword); utils.setInputValue("#input-markdownextra-highlighter", markdownExtra.config.highlighter); }; @@ -53,6 +55,7 @@ define([ utils.getInputChecked("#input-markdownextra-smartypants") && newConfig.extensions.push("smartypants"); utils.getInputChecked("#input-markdownextra-strikethrough") && newConfig.extensions.push("strikethrough"); utils.getInputChecked("#input-markdownextra-newlines") && newConfig.extensions.push("newlines"); + newConfig.intraword = utils.getInputChecked("#input-markdownextra-intraword"); newConfig.highlighter = utils.getInputValue("#input-markdownextra-highlighter"); }; @@ -63,11 +66,22 @@ define([ markdownExtra.onPagedownConfigure = function(editor) { var converter = editor.getConverter(); - var options = { + if(markdownExtra.config.intraword === true) { + var converterOptions = { + _DoItalicsAndBold: function(text) { + text = text.replace(/([^\w*]|^)(\*\*|__)(?=\S)(.+?[*_]*)(?=\S)\2(?=[^\w*]|$)/g, "$1$3"); + text = text.replace(/([^\w*]|^)(\*|_)(?=\S)(.+?)(?=\S)\2(?=[^\w*]|$)/g, "$1$3"); + return text; + } + }; + converter.setOptions(converterOptions); + } + + var extraOptions = { extensions: markdownExtra.config.extensions }; if(markdownExtra.config.highlighter == "highlight") { - options.highlighter = "prettify"; + extraOptions.highlighter = "prettify"; var previewContentsElt = document.getElementById('preview-contents'); editor.hooks.chain("onPreviewRefresh", function() { _.each(previewContentsElt.querySelectorAll('.prettyprint > code'), function(elt) { @@ -76,10 +90,10 @@ define([ }); } else if(markdownExtra.config.highlighter == "prettify") { - options.highlighter = "prettify"; + extraOptions.highlighter = "prettify"; editor.hooks.chain("onPreviewRefresh", prettify.prettyPrint); } - Markdown.Extra.init(converter, options); + Markdown.Extra.init(converter, extraOptions); }; return markdownExtra; diff --git a/public/res/html/markdownExtraSettingsBlock.html b/public/res/html/markdownExtraSettingsBlock.html index f07b10ac..5ca59974 100644 --- a/public/res/html/markdownExtraSettingsBlock.html +++ b/public/res/html/markdownExtraSettingsBlock.html @@ -53,6 +53,15 @@ +