Compare commits

...

7 Commits

Author SHA1 Message Date
Samy Pesse 7e8f1a9632 Bump version to 3.0.1 2016-05-25 20:00:04 +02:00
Samy Pesse 8469648241 Update theme-default@1.0.2 2016-05-25 17:14:15 +02:00
Samy Pessé e7a44358a5 Update Changelog 2016-05-24 15:38:26 +02:00
Samy Pessé fb930d889f Fix anchor breaking links resolution 2016-05-24 15:32:30 +02:00
Samy Pessé 721a75309b Fix #1316: adapt regexp to handle dot in filenames 2016-05-23 13:00:01 +02:00
Samy Pessé b856bff91b Add failing test for #1316 2016-05-23 12:48:46 +02:00
Samy Pesse 0744f000f9 Fix doc for conrefs 2016-05-22 19:59:53 +02:00
8 changed files with 75 additions and 12 deletions
+5 -1
View File
@@ -2,7 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).
## 3.0.0 (pre)
## 3.0.1
- Fix regression in link resolution when contain anchor
- Fix `structure.<name>` configuration not supporting filenames with dots
## 3.0.0
- Summary can contain external links and anchors (Fix [#776](https://github.com/GitbookIO/gitbook/issues/776))
- Summary can contain differents entitled sections
- Glossary is generated as a normal page
+1 -1
View File
@@ -51,5 +51,5 @@ This is the default content
# License
{% import "./LICENSE" %}
{% include "./LICENSE" %}
```
+36
View File
@@ -0,0 +1,36 @@
var jsonschema = require('jsonschema');
var schema = require('../configSchema');
describe('configSchema', function() {
function validate(cfg) {
var v = new jsonschema.Validator();
return v.validate(cfg, schema, {
propertyName: 'config'
});
}
describe('structure', function() {
it('should accept dot in filename', function() {
var result = validate({
structure: {
readme: 'book-intro.adoc'
}
});
expect(result.errors.length).toBe(0);
});
it('should not accept filepath', function() {
var result = validate({
structure: {
readme: 'folder/myFile.md'
}
});
expect(result.errors.length).toBe(1);
});
});
});
+6 -4
View File
@@ -1,3 +1,5 @@
var FILENAME_REGEX = '^[a-z-._\d,\s]+$';
module.exports = {
'$schema': 'http://json-schema.org/schema#',
'id': 'https://gitbook.com/schemas/book.json',
@@ -57,25 +59,25 @@ module.exports = {
'default': 'LANGS.md',
'type': 'string',
'title': 'File to use as languages index',
'pattern': '^[0-9a-zA-Z ... ]+$'
'pattern': FILENAME_REGEX
},
'readme': {
'default': 'README.md',
'type': 'string',
'title': 'File to use as preface',
'pattern': '^[0-9a-zA-Z ... ]+$'
'pattern': FILENAME_REGEX
},
'glossary': {
'default': 'GLOSSARY.md',
'type': 'string',
'title': 'File to use as glossary index',
'pattern': '^[0-9a-zA-Z ... ]+$'
'pattern': FILENAME_REGEX
},
'summary': {
'default': 'SUMMARY.md',
'type': 'string',
'title': 'File to use as table of contents',
'pattern': '^[0-9a-zA-Z ... ]+$'
'pattern': FILENAME_REGEX
}
},
'additionalProperties': false
-1
View File
@@ -4,7 +4,6 @@ var Promise = require('../utils/promise');
var error = require('../utils/error');
var timing = require('../utils/timing');
var Parse = require('../parse');
var Templating = require('../templating');
var JSONUtils = require('../json');
var createTemplateEngine = require('./createTemplateEngine');
+17 -3
View File
@@ -4,7 +4,7 @@ var resolveLinks = require('../resolveLinks');
describe('resolveLinks', function() {
function resolveFileBasic(href) {
return href;
return 'fakeDir/' + href;
}
function resolveFileCustom(href) {
@@ -24,7 +24,7 @@ describe('resolveLinks', function() {
return resolveLinks('hello.md', resolveFileBasic, $)
.then(function() {
var link = $('a');
expect(link.attr('href')).toBe('test/cool.md');
expect(link.attr('href')).toBe('fakeDir/test/cool.md');
});
});
@@ -34,7 +34,21 @@ describe('resolveLinks', function() {
return resolveLinks('afolder/hello.md', resolveFileBasic, $)
.then(function() {
var link = $('a');
expect(link.attr('href')).toBe('../test/cool.md');
expect(link.attr('href')).toBe('../fakeDir/test/cool.md');
});
});
});
describe('Anchor', function() {
var TEST = '<p>This is a <a href="test/cool.md#an-anchor"></a></p>';
it('should prevent anchors in resolution', function() {
var $ = cheerio.load(TEST);
return resolveLinks('hello.md', resolveFileCustom, $)
.then(function() {
var link = $('a');
expect(link.attr('href')).toBe('test/cool.html#an-anchor');
});
});
});
+8
View File
@@ -1,4 +1,5 @@
var path = require('path');
var url = require('url');
var LocationUtils = require('../../utils/location');
var editHTMLElement = require('./editHTMLElement');
@@ -27,6 +28,10 @@ function resolveLinks(currentFile, resolveFile, $) {
return;
}
// Split anchor
var parsed = url.parse(href);
href = parsed.pathname;
// Calcul absolute path for this
href = LocationUtils.toAbsolute(href, currentDirectory, '.');
@@ -36,6 +41,9 @@ function resolveLinks(currentFile, resolveFile, $) {
// Convert back to relative
href = LocationUtils.relative(currentDirectory, href);
// Add back anchor
href = href + (parsed.hash || '');
$a.attr('href', href);
});
}
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "gitbook",
"version": "3.0.0",
"version": "3.0.1",
"homepage": "https://www.gitbook.com",
"description": "Library and cmd utility to generate GitBooks",
"main": "lib/index.js",
@@ -29,7 +29,7 @@
"gitbook-plugin-lunr": "1.1.0",
"gitbook-plugin-search": "2.2.1",
"gitbook-plugin-sharing": "1.0.2",
"gitbook-plugin-theme-default": "1.0.1",
"gitbook-plugin-theme-default": "1.0.2",
"github-slugid": "1.0.1",
"graceful-fs": "4.1.4",
"i18n-t": "1.0.0",