File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -224,6 +224,7 @@ Available configuration options for the `[output.html.print]` table:
224
224
225
225
- ** enable:** Enable print support. When ` false ` , all print support will not be
226
226
rendered. Defaults to ` true ` .
227
+ - ** page-break** Insert page breaks between chapters. Defaults to ` true ` .
227
228
228
229
Available configuration options for the ` [output.html.fold] ` table:
229
230
@@ -292,6 +293,7 @@ input-404 = "not-found.md"
292
293
293
294
[output .html .print ]
294
295
enable = true
296
+ page-break = true
295
297
296
298
[output .html .fold ]
297
299
enable = false
Original file line number Diff line number Diff line change @@ -580,11 +580,16 @@ impl HtmlConfig {
580
580
pub struct Print {
581
581
/// Whether print support is enabled.
582
582
pub enable : bool ,
583
+ /// Insert page breaks between chapters. Default: `true`.
584
+ pub page_break : bool ,
583
585
}
584
586
585
587
impl Default for Print {
586
588
fn default ( ) -> Self {
587
- Self { enable : true }
589
+ Self {
590
+ enable : true ,
591
+ page_break : true ,
592
+ }
588
593
}
589
594
}
590
595
Original file line number Diff line number Diff line change @@ -45,6 +45,12 @@ impl HtmlHandlebars {
45
45
ctx. html_config . curly_quotes ,
46
46
Some ( & path) ,
47
47
) ;
48
+ if !ctx. is_index && ctx. html_config . print . page_break {
49
+ // Add page break between chapters
50
+ // 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
51
+ // Add both two CSS properties because of the compatibility issue
52
+ print_content. push_str ( r#"<div id="chapter_begin" style="break-before: page; page-break-before: always;"></div>"# ) ;
53
+ }
48
54
print_content. push_str ( & fixed_content) ;
49
55
50
56
// Update the context with data for this file
You can’t perform that action at this time.
0 commit comments