From 085caa9370951ac84bddd3e549d0cb3c3dfc6967 Mon Sep 17 00:00:00 2001
From: Hannah Wolfe
');
- content = converter.makeHtml(content);
- content = content.replace(/<\/p>$/, '');
- var s = '
[\s\S]*?<\/pre>/gim, function (x) { - var hash = hashId(); - extractions[hash] = x; - return '{gfm-js-extract-pre-' + hash + '}'; - }, 'm'); - - // Extract code blocks - text = text.replace(/```[\s\S]*```/gim, function (x) { - var hash = hashId(); - extractions[hash] = x; - return '{gfm-js-extract-code-' + hash + '}'; - }, 'm'); - - // prevent foo_bar and foo_bar_baz from ending up with an italic word in the middle - text = text.replace(/(^(?! {4}|\t)(?!__)\w+_\w+_\w[\w_]*)/gm, function (x) { - return x.replace(/_/gm, '\\_'); - }); - - text = text.replace(/\{gfm-js-extract-code-([0-9]+)\}/gm, function (x, y) { - return extractions[y]; - }); - - // in very clear cases, let newlines become
tags - /*jshint -W049 */ - text = text.replace(/^[\w\<\'\'][^\n]*\n+/gm, function (x) { - return x.match(/\n{2}/) ? x : x.trim() + ' \n'; - }); - /*jshint +W049 */ - - // better URL support, but no title support - text = text.replace(imageMarkdownRegex, function (match, key, alt, src) { - if (src) { - return ''; - } - - return ''; - }); - - text = text.replace(/\{gfm-js-extract-pre-([0-9]+)\}/gm, function (x, y) { - return '\n\n' + extractions[y]; - }); - - return text; - } - }, - - // 4 or more inline underscores e.g. Ghost rocks my _____! - { - type: 'lang', - filter: function (text) { - return text.replace(/([^_\n\r])(_{4,})/g, function (match, prefix, underscores) { - return prefix + underscores.replace(/_/g, '_'); - }); - } - }, - - { - // GFM autolinking & custom image handling, happens AFTER showdown - type: 'html', - filter: function (text) { - var refExtractions = {}, - preExtractions = {}, - hashID = 0; - - function hashId() { - /*jshint plusplus:false*/ - return hashID++; - } - - // Extract pre blocks - text = text.replace(/<(pre|code)>[\s\S]*?<\/(\1)>/gim, function (x) { - var hash = hashId(); - preExtractions[hash] = x; - return '{gfm-js-extract-pre-' + hash + '}'; - }, 'm'); - - // filter out def urls - // from Marked https://github.com/chjj/marked/blob/master/lib/marked.js#L24 - text = text.replace(/^ *\[([^\]]+)\]: *([^\s>]+)>?(?: +["(]([^\n]+)[")])? *(?:\n+|$)/gmi, - function (x) { - var hash = hashId(); - refExtractions[hash] = x; - return '{gfm-js-extract-ref-url-' + hash + '}'; - }); - - // match a URL - // adapted from https://gist.github.com/jorilallo/1283095#L158 - // and http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript - /*jshint -W049 */ - text = text.replace(/(\]\(|\]|\[|]*?\>)?https?\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!]/gmi, - function (wholeMatch, lookBehind, matchIndex) { - // Check we are not inside an HTML tag - var left = text.slice(0, matchIndex), right = text.slice(matchIndex); - if ((left.match(/<[^>]+$/) && right.match(/^[^>]*>/)) || lookBehind) { - return wholeMatch; - } - // If we have a matching lookBehind, this is a failure, else wrap the match in tag - return lookBehind ? wholeMatch : '' + wholeMatch + ''; - }); - /*jshint +W049 */ - - // replace extractions - text = text.replace(/\{gfm-js-extract-pre-([0-9]+)\}/gm, function (x, y) { - return preExtractions[y]; - }); - - text = text.replace(/\{gfm-js-extract-ref-url-([0-9]+)\}/gi, function (x, y) { - return '\n\n' + refExtractions[y]; - }); - - return text; - } - } - ]; - }; - - // Client-side export - if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { - window.Showdown.extensions.ghostgfm = ghostgfm; - } - // Server-side export - if (typeof module !== 'undefined') { - module.exports = ghostgfm; - } -}()); diff --git a/ghost/admin/vendor/showdown/extensions/ghosthighlight.js b/ghost/admin/vendor/showdown/extensions/ghosthighlight.js deleted file mode 100644 index b867b0183b..0000000000 --- a/ghost/admin/vendor/showdown/extensions/ghosthighlight.js +++ /dev/null @@ -1,71 +0,0 @@ -/* jshint node:true, browser:true, -W044 */ - -// Adds highlight syntax as per RedCarpet: -// -// https://github.com/vmg/redcarpet -// -// This is ==highlighted==. It looks like this: highlighted - -(function () { - var highlight = function () { - return [ - { - type: 'html', - filter: function (text) { - var highlightRegex = /(=){2}([\s\S]+?)(=){2}/gim, - preExtractions = {}, - codeExtractions = {}, - hashID = 0; - - function hashId() { - return hashID += 1; - } - - // Extract pre blocks - text = text.replace(/[\s\S]*?<\/pre>/gim, function (x) { - var hash = hashId(); - preExtractions[hash] = x; - return '{gfm-js-extract-pre-' + hash + '}'; - }, 'm'); - - // Extract code blocks - text = text.replace(/[\s\S]*?<\/code>/gim, function (x) { - var hash = hashId(); - codeExtractions[hash] = x; - return '{gfm-js-extract-code-' + hash + '}'; - }, 'm'); - - text = text.replace(highlightRegex, function (match, n, content) { - // Check the content isn't just an `=` - if (!/^=+$/.test(content)) { - return '' + content + ''; - } - - return match; - }); - - // replace pre extractions - text = text.replace(/\{gfm-js-extract-pre-([0-9]+)\}/gm, function (x, y) { - return preExtractions[y]; - }); - - // replace code extractions - text = text.replace(/\{gfm-js-extract-code-([0-9]+)\}/gm, function (x, y) { - return codeExtractions[y]; - }); - - return text; - } - } - ]; - }; - - // Client-side export - if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { - window.Showdown.extensions.highlight = highlight; - } - // Server-side export - if (typeof module !== 'undefined') { - module.exports = highlight; - } -}()); diff --git a/ghost/admin/vendor/showdown/extensions/ghostimagepreview.js b/ghost/admin/vendor/showdown/extensions/ghostimagepreview.js deleted file mode 100644 index 5974c4e5b7..0000000000 --- a/ghost/admin/vendor/showdown/extensions/ghostimagepreview.js +++ /dev/null @@ -1,51 +0,0 @@ -/* jshint node:true, browser:true */ - -// Ghost Image Preview -// -// Manages the conversion of image markdown `![]()` from markdown into the HTML image preview -// This provides a dropzone and other interface elements for adding images -// Is only used in the admin client. - -var Ghost = Ghost || {}; -(function () { - var ghostimagepreview = function () { - return [ - // ![] image syntax - { - type: 'lang', - filter: function (text) { - var imageMarkdownRegex = /^!(?:\[([^\n\]]*)\])(?:\(([^\n\]]*)\))?$/gim, - /* regex from isURL in node-validator. Yum! */ - uriRegex = /^(?!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, - pathRegex = /^(\/)?([^\/\0]+(\/)?)+$/i; - - return text.replace(imageMarkdownRegex, function (match, alt, src) { - var result = '', - output; - - if (src && (src.match(uriRegex) || src.match(pathRegex))) { - result = ''; - } - - output = '
' + - result + - ' '; - - return output; - }); - } - } - ]; - }; - - // Client-side export - if (typeof window !== 'undefined' && window.Showdown && window.Showdown.extensions) { - window.Showdown.extensions.ghostimagepreview = ghostimagepreview; - } - // Server-side export - if (typeof module !== 'undefined') { - module.exports = ghostimagepreview; - } -}());Add image of ' + alt + '' + - '' + - '