Compare commits

..

5 Commits

Author SHA1 Message Date
Samy Pessé e7f2803d11 Bump version to 2.3.2 2015-09-09 09:30:53 +02:00
Samy Pessé 320015dd8f Fix #910: fix stupid error with semver api 2015-09-09 09:27:08 +02:00
Samy Pessé 471c124a98 Merge pull request #908 from GitbookIO/fix/asciidoc_blocks
Fix blocks in asciidoc
2015-09-09 00:01:43 +02:00
Samy Pesse aa44a109c6 Use position indicator that doesn't conflict with asciidoc 2015-09-08 23:57:40 +02:00
Samy Pesse 41e5ca8422 Add test for blocks without parsing 2015-09-08 23:55:30 +02:00
5 changed files with 45 additions and 7 deletions
+4
View File
@@ -2,6 +2,10 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 2.3.2
- Fix blocks (like maths) in Asciidoc
- Fix error when checking gitbook version
## 2.3.1
- Fix black font color for ebooks (mobi, pdf and epub)
- Fix ISO code for korean language
+1 -1
View File
@@ -121,7 +121,7 @@ Configuration.prototype.load = function() {
if (!semver.satisfies(pkg.version, that.options.gitbook)) {
throw "GitBook version doesn't satisfy version required by the book: "+that.options.gitbook;
}
if (that.options.gitbook != '*' && !semver.satisfies(that.options.gitbook, semver.inc(pkg.version, 'patch'))) {
if (that.options.gitbook != '*' && !semver.satisfies(semver.inc(pkg.version, 'patch'), that.options.gitbook)) {
that.book.log.warn.ln("gitbook version specified in your book.json might be too strict for future patches, \""+(_.first(pkg.version.split("."))+".x.x")+"\" is more adequate");
}
+5 -5
View File
@@ -103,16 +103,16 @@ TemplateEngine.prototype.processBlock = function(blk) {
return blk.body;
}
// Return it as a macro
return "%+%"+blk.id+"%+%";
// Return it as a position marker
return "@%@"+blk.id+"@%@";
};
// Replace blocks by body after processing
// This is done to avoid that markdown processer parse the block content
// Replace position markers of blocks by body after processing
// This is done to avoid that markdown/asciidoc processer parse the block content
TemplateEngine.prototype.replaceBlocks = function(content) {
var that = this;
return content.replace(/\%\+\%([\s\S]+?)\%\+\%/g, function(match, key) {
return content.replace(/\@\%\@([\s\S]+?)\@\%\@/g, function(match, key) {
var blk = that.blocks[key];
if (!blk) return match;
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "2.3.1",
"version": "2.3.2",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
+34
View File
@@ -3,6 +3,7 @@ var should = require('should');
var path = require('path');
var Plugin = require('../lib/plugin');
var parsers = require("gitbook-parsers");
var PLUGINS_ROOT = path.resolve(__dirname, 'plugins');
describe('Plugins', function () {
@@ -200,5 +201,38 @@ describe('Plugins', function () {
});
});
});
describe('Blocks without parsing', function() {
var plugin;
before(function() {
plugin = new Plugin(book, "blocks");
plugin.load("./blocks", PLUGINS_ROOT);
return book.plugins.load(plugin);
});
var testTpl = function(markup, str, args, options) {
var filetype = parsers.get(markup);
return book.template.renderString(str, args, options)
.then(filetype.page).get('sections').get(0).get('content')
.then(book.template.postProcess)
};
it('should correctly process unparsable for markdown', function() {
return testTpl('.md', '{% test %}**hello**{% endtest %}')
.then(function(content) {
content.should.equal("<p>test**hello**test</p>\n");
});
});
it('should correctly process unparsable for asciidoc', function() {
return testTpl('.adoc', '{% test %}**hello**{% endtest %}')
.then(function(content) {
content.should.equal('<div class="paragraph">\n<p>test**hello**test</p>\n</div>');
});
});
});
});