Skip to content

Commit 4aa8e66

Browse files
committed
Merge pull request GitbookIO#813 from MrMaksimize/pdf-options
Allowing for custom chapter-mark and page-break in PDF.
2 parents 2f5e53d + 917a6f7 commit 4aa8e66

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

lib/configuration.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,14 @@ Configuration.DEFAULT = {
246246
// Choices are [u’a0’, u’a1’, u’a2’, u’a3’, u’a4’, u’a5’, u’a6’, u’b0’, u’b1’, u’b2’, u’b3’, u’b4’, u’b5’, u’b6’, u’legal’, u’letter’]
247247
"paperSize": "a4",
248248

249+
// How to mark detected chapters.
250+
// Choices are “pagebreak”, “rule”, "both" or “none”.
251+
"chapterMark" : "pagebreak",
252+
253+
// An XPath expression. Page breaks are inserted before the specified elements.
254+
// To disable use the expression: "/"
255+
"pageBreaksBefore": "/",
256+
249257
// Margin (in pts)
250258
// Note: 72 pts equals 1 inch
251259
"margin": {

lib/generators/ebook.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ Generator.prototype.finish = function() {
6868
"--book-producer": "GitBook",
6969
"--publisher": "GitBook",
7070
"--chapter": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter ')]",
71-
"--chapter-mark": "pagebreak",
72-
"--page-breaks-before": "/",
7371
"--level1-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-1 ')]",
7472
"--level2-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-2 ')]",
7573
"--level3-toc": "descendant-or-self::*[contains(concat(' ', normalize-space(@class), ' '), ' book-chapter-3 ')]",
@@ -82,6 +80,8 @@ Generator.prototype.finish = function() {
8280
var pdfOptions = that.options.pdf;
8381

8482
_.extend(_options, {
83+
"--chapter-mark": String(pdfOptions.chapterMark),
84+
"--page-breaks-before": String(pdfOptions.pageBreaksBefore),
8585
"--margin-left": String(pdfOptions.margin.left),
8686
"--margin-right": String(pdfOptions.margin.right),
8787
"--margin-top": String(pdfOptions.margin.top),

0 commit comments

Comments
 (0)