Skip to content

Commit 2213312

Browse files
authored
Merge pull request #1728 from dmorawetz/master
Make page-break configurable
2 parents 0ec4b69 + 9e62178 commit 2213312

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

guide/src/format/configuration/renderers.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,10 +173,12 @@ By default, mdBook will include an icon on the top right of the book (which look
173173
```toml
174174
[output.html.print]
175175
enable = true # include support for printable output
176+
page-break = true # insert page-break after each chapter
176177
```
177178

178179
- **enable:** Enable print support. When `false`, all print support will not be
179180
rendered. Defaults to `true`.
181+
- **page-break** Insert page breaks between chapters. Defaults to `true`.
180182

181183
### `[output.html.fold]`
182184

src/config.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,16 @@ impl HtmlConfig {
592592
pub struct Print {
593593
/// Whether print support is enabled.
594594
pub enable: bool,
595+
/// Insert page breaks between chapters. Default: `true`.
596+
pub page_break: bool,
595597
}
596598

597599
impl Default for Print {
598600
fn default() -> Self {
599-
Self { enable: true }
601+
Self {
602+
enable: true,
603+
page_break: true,
604+
}
600605
}
601606
}
602607

src/renderer/html_handlebars/hbs_renderer.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ impl HtmlHandlebars {
5656

5757
let fixed_content =
5858
utils::render_markdown_with_path(&ch.content, ctx.html_config.curly_quotes, Some(path));
59-
if !ctx.is_index {
59+
if !ctx.is_index && ctx.html_config.print.page_break {
6060
// Add page break between chapters
6161
// 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
6262
// Add both two CSS properties because of the compatibility issue

0 commit comments

Comments
 (0)