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:
parent
6bb5fdd757
commit
24673b4943
3 changed files with 8 additions and 7 deletions
|
@ -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 +
|
||||||
|
|
|
@ -140,7 +140,7 @@
|
||||||
strike: "~~$1~~",
|
strike: "~~$1~~",
|
||||||
code: "`$1`",
|
code: "`$1`",
|
||||||
link: "[$1](http://)",
|
link: "[$1](http://)",
|
||||||
image: "!image[$1](http://)",
|
image: "",
|
||||||
blockquote: "> $1"
|
blockquote: "> $1"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -34,7 +34,7 @@
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Image</td>
|
<td>Image</td>
|
||||||
<td>!image[image](http://)</td>
|
<td></td>
|
||||||
<td>Ctrl + Shift + I</td>
|
<td>Ctrl + Shift + I</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
Loading…
Add table
Reference in a new issue