diff --git a/core/client/assets/vendor/showdown/extensions/ghostdown.js b/core/client/assets/vendor/showdown/extensions/ghostdown.js index dbe0cee149..edc996b9a2 100644 --- a/core/client/assets/vendor/showdown/extensions/ghostdown.js +++ b/core/client/assets/vendor/showdown/extensions/ghostdown.js @@ -1,14 +1,15 @@ (function () { - var ghostdown = function (converter) { + var ghostdown = function () { return [ - // [image] syntax + // ![] image syntax { type: 'lang', - filter: function (source) { - return source.replace(/\n?!(?:image)?\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, src) { + filter: function (text) { + return text.replace(/\n?!\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, src) { var result = ""; - if (src !== "http://") { + /* regex from isURL in node-validator. Yum! */ + if (src && src.match(/^(?!mailto:)(?:(?:https?|ftp):\/\/)?(?:\S+(?::\S*)?@)?(?:(?:(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[0-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]+-?)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})))|localhost)(?::\d{2,5})?(?:\/[^\s]*)?$/i)) { result = ''; } return '
' + result + diff --git a/core/client/markdown-actions.js b/core/client/markdown-actions.js index f76d826983..256ab5700c 100644 --- a/core/client/markdown-actions.js +++ b/core/client/markdown-actions.js @@ -140,7 +140,7 @@ strike: "~~$1~~", code: "`$1`", link: "[$1](http://)", - image: "!image[$1](http://)", + image: "![$1](http://)", blockquote: "> $1" } }; diff --git a/core/client/tpl/modals/markdown.hbs b/core/client/tpl/modals/markdown.hbs index 612e4039df..8533660988 100644 --- a/core/client/tpl/modals/markdown.hbs +++ b/core/client/tpl/modals/markdown.hbs @@ -34,7 +34,7 @@ Image - !image[image](http://) + ![alt](http://) Ctrl + Shift + I diff --git a/core/test/unit/frontend_ghostdown_spec.js b/core/test/unit/frontend_ghostdown_spec.js index 7801fe40d5..dc6f98d958 100644 --- a/core/test/unit/frontend_ghostdown_spec.js +++ b/core/test/unit/frontend_ghostdown_spec.js @@ -21,7 +21,7 @@ describe("Ghostdown showdown extensions", function () { it("should accurately detect images in markdown", function () { - [ "!image[image and another,/ image](http://dsurl stuff)", + [ "![image and another,/ image](http://dsurl stuff)", "![image and another,/ image]", "![]()", "![]" ]