From 7b1241d0f287e07a0056834020726f5a1e69f5a8 Mon Sep 17 00:00:00 2001 From: Daniel Morawetz Date: Mon, 17 Jan 2022 18:03:52 +0100 Subject: [PATCH 1/2] Revert "Make page-break not configurable" This reverts commit 0eb23efd44c96d79c96161648a6c286dbc7424c1. --- src/config.rs | 7 ++++++- src/renderer/html_handlebars/hbs_renderer.rs | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index bf4aabbb..daeccbd0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -592,11 +592,16 @@ impl HtmlConfig { pub struct Print { /// Whether print support is enabled. pub enable: bool, + /// Insert page breaks between chapters. Default: `true`. + pub page_break: bool, } impl Default for Print { fn default() -> Self { - Self { enable: true } + Self { + enable: true, + page_break: true, + } } } diff --git a/src/renderer/html_handlebars/hbs_renderer.rs b/src/renderer/html_handlebars/hbs_renderer.rs index e8da5b4a..69dc3124 100644 --- a/src/renderer/html_handlebars/hbs_renderer.rs +++ b/src/renderer/html_handlebars/hbs_renderer.rs @@ -56,7 +56,7 @@ impl HtmlHandlebars { let fixed_content = utils::render_markdown_with_path(&ch.content, ctx.html_config.curly_quotes, Some(path)); - if !ctx.is_index { + if !ctx.is_index && ctx.html_config.print.page_break { // Add page break between chapters // See https://developer.mozilla.org/en-US/docs/Web/CSS/break-before and https://developer.mozilla.org/en-US/docs/Web/CSS/page-break-before // Add both two CSS properties because of the compatibility issue From 9e6217871e8f7b7580703c4f0cd99938ee0a3e19 Mon Sep 17 00:00:00 2001 From: Daniel Morawetz Date: Mon, 17 Jan 2022 18:07:22 +0100 Subject: [PATCH 2/2] add page-break option to docs --- guide/src/format/configuration/renderers.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/guide/src/format/configuration/renderers.md b/guide/src/format/configuration/renderers.md index a29265e4..1aa1eef9 100644 --- a/guide/src/format/configuration/renderers.md +++ b/guide/src/format/configuration/renderers.md @@ -173,10 +173,12 @@ By default, mdBook will include an icon on the top right of the book (which look ```toml [output.html.print] enable = true # include support for printable output +page-break = true # insert page-break after each chapter ``` - **enable:** Enable print support. When `false`, all print support will not be rendered. Defaults to `true`. +- **page-break** Insert page breaks between chapters. Defaults to `true`. ### `[output.html.fold]`