mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 05:37:34 +03:00
5ff0a2816b
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
38 lines
1.4 KiB
JavaScript
38 lines
1.4 KiB
JavaScript
/*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 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*$/);
|
|
});
|
|
});
|
|
}); |