0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-10 23:36:14 -05:00

Further fix to image markdown

issue #866 again
This commit is contained in:
Hannah Wolfe 2013-09-27 14:17:19 +01:00
parent d841e749f9
commit e86958fdb7

View file

@ -20,6 +20,7 @@
type : 'lang',
filter : function (text) {
var preExtractions = {},
imageMarkdownRegex = /^(?:\{(.*?)\})?!(?:\[([^\n\]]*)\])(?:\(([^\n\]]*)\))?$/gim,
hashID = 0;
function hashId() {
@ -43,6 +44,14 @@
return x.match(/\n{2}/) ? x : x.trim() + " \n";
});
// better URL support, but no title support
text = text.replace(imageMarkdownRegex, function (match, key, alt, src) {
if (src) {
return '<img src="' + src + '" alt="' + alt + '" />';
}
return '';
});
text = text.replace(/\{gfm-js-extract-pre-([0-9]+)\}/gm, function (x, y) {
return "\n\n" + preExtractions[y];
@ -58,7 +67,6 @@
filter : function (text) {
var refExtractions = {},
preExtractions = {},
imageMarkdownRegex = /^(?:\{(.*?)\})?!(?:\[([^\n\]]*)\])(?:\(([^\n\]]*)\))?$/gim,
hashID = 0;
function hashId() {
@ -81,15 +89,6 @@
return "{gfm-js-extract-ref-url-" + hash + "}";
});
// better URL support, but no title support
text = text.replace(imageMarkdownRegex, function (match, key, alt, src) {
if (src) {
return '<img src="' + src + '" alt="' + alt + '" />';
}
return '';
});
// match a URL
// adapted from https://gist.github.com/jorilallo/1283095#L158
// and http://blog.stevenlevithan.com/archives/mimic-lookbehind-javascript