0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Dropping !image[] & other regex fixes

closes #452

- changed keyboard shortcut to insert ![].. not !image[]
- changed regex in ghostdown to only work for ![]
- added a further regex in ghostdown to properly match for URLs inside the parens
This commit is contained in:
Hannah Wolfe 2013-08-20 21:16:40 +01:00
parent 6bb5fdd757
commit 24673b4943
3 changed files with 8 additions and 7 deletions

View file

@ -1,14 +1,15 @@
(function () { (function () {
var ghostdown = function (converter) { var ghostdown = function () {
return [ return [
// [image] syntax // ![] image syntax
{ {
type: 'lang', type: 'lang',
filter: function (source) { filter: function (text) {
return source.replace(/\n?!(?:image)?\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, src) { return text.replace(/\n?!\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, src) {
var result = ""; 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 = '<img class="js-upload-target" src="' + src + '"/>'; result = '<img class="js-upload-target" src="' + src + '"/>';
} }
return '<section class="js-drop-zone image-uploader">' + result + return '<section class="js-drop-zone image-uploader">' + result +

View file

@ -140,7 +140,7 @@
strike: "~~$1~~", strike: "~~$1~~",
code: "`$1`", code: "`$1`",
link: "[$1](http://)", link: "[$1](http://)",
image: "!image[$1](http://)", image: "![$1](http://)",
blockquote: "> $1" blockquote: "> $1"
} }
}; };

View file

@ -34,7 +34,7 @@
</tr> </tr>
<tr> <tr>
<td>Image</td> <td>Image</td>
<td>!image[image](http://)</td> <td>![alt](http://)</td>
<td>Ctrl + Shift + I</td> <td>Ctrl + Shift + I</td>
</tr> </tr>
<tr> <tr>