mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Merge pull request #317 from cgiffard/image-dropzone-regex
Updated Ghostdown image regex
This commit is contained in:
commit
4ea9d77b11
2 changed files with 39 additions and 1 deletions
|
@ -5,7 +5,7 @@
|
|||
{
|
||||
type: 'lang',
|
||||
filter: function (source) {
|
||||
return source.replace(/\n?!image\[([\d\w\s]*)\]/gi, function (match, alt, a) {
|
||||
return source.replace(/\n?!(?:image)?\[([^\n\]]*)\](?:\(([^\n\)]*)\))?/gi, function (match, alt, a) {
|
||||
return '<section class="js-drop-zone image-uploader">' +
|
||||
'<span class="media"><span class="hidden">Image Upload</span></span>' +
|
||||
'<div class="description">Add image of <strong>' + alt + '</strong></div>' +
|
||||
|
|
38
core/test/unit/frontend_ghostdown_spec.js
Normal file
38
core/test/unit/frontend_ghostdown_spec.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*globals describe, it */
|
||||
var gdPath = "../../client/assets/vendor/showdown/extensions/ghostdown.js",
|
||||
should = require('should'),
|
||||
ghostdown = require(gdPath);
|
||||
|
||||
describe("Ghostdown showdown extensions", function () {
|
||||
|
||||
it("should export an array of methods for processing", function () {
|
||||
|
||||
ghostdown.should.be.a("function");
|
||||
ghostdown().should.be.an.instanceof(Array);
|
||||
|
||||
ghostdown().forEach(function (processor) {
|
||||
processor.should.be.a("object");
|
||||
processor.should.have.property("type");
|
||||
processor.should.have.property("filter");
|
||||
processor.type.should.be.a("string");
|
||||
processor.filter.should.be.a("function");
|
||||
});
|
||||
});
|
||||
|
||||
it("should accurately detect images in markdown", function () {
|
||||
|
||||
[ "!image[image and another,/ image](http://dsurl stuff)",
|
||||
"![image and another,/ image]",
|
||||
"![]()",
|
||||
"![]" ]
|
||||
.forEach(function (imageMarkup) {
|
||||
var processedMarkup =
|
||||
ghostdown().reduce(function(prev,processor) {
|
||||
return processor.filter(prev);
|
||||
},imageMarkup);
|
||||
|
||||
// The image is the entire markup, so the image box should be too
|
||||
processedMarkup.should.match(/^<section.*?section>\n*$/);
|
||||
});
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue