Merge pull request #1728 from dmorawetz/master

Make page-break configurable
This commit is contained in:
Eric Huss 2022-01-30 14:25:02 -08:00 committed by GitHub
commit 2213312938
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 2 deletions

View File

@ -173,10 +173,12 @@ By default, mdBook will include an icon on the top right of the book (which look
```toml ```toml
[output.html.print] [output.html.print]
enable = true # include support for printable output 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 - **enable:** Enable print support. When `false`, all print support will not be
rendered. Defaults to `true`. rendered. Defaults to `true`.
- **page-break** Insert page breaks between chapters. Defaults to `true`.
### `[output.html.fold]` ### `[output.html.fold]`

View File

@ -592,11 +592,16 @@ impl HtmlConfig {
pub struct Print { pub struct Print {
/// Whether print support is enabled. /// Whether print support is enabled.
pub enable: bool, pub enable: bool,
/// Insert page breaks between chapters. Default: `true`.
pub page_break: bool,
} }
impl Default for Print { impl Default for Print {
fn default() -> Self { fn default() -> Self {
Self { enable: true } Self {
enable: true,
page_break: true,
}
} }
} }

View File

@ -56,7 +56,7 @@ impl HtmlHandlebars {
let fixed_content = let fixed_content =
utils::render_markdown_with_path(&ch.content, ctx.html_config.curly_quotes, Some(path)); 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 // 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 // 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 // Add both two CSS properties because of the compatibility issue