Fixing the styling issues of the empty pages caused by pagebreak#2182
Fixing the styling issues of the empty pages caused by pagebreak#2182laurmaedje merged 8 commits intotypst:mainfrom
Conversation
|
Since |
Updated with a revised approach that get rid of the get mut reference. |
|
Thanks! I've pushed a minor revision to not require an extra field on |
Great! Thank you! It is much more neat solution. I am still transfering from C and not quite familiar to the option handling conventions of Rust. BTW, should we be able to close the two issues #2162 and #2095 since this is merged? |
Updated Sep 23
Revise the modification according as suggested, now the logic is a little bit deep, but now we get rid of the mutable reference.
The two newly added tests are functioning the same, as expected.
Old
Caveat: Added an API to get mutable reference
This is solving two related issues #2095 and #2162. Tests for both issues are appended.
The problems of the styles of pagebreaks stem from the fact that when we scan the following command
The layout engine would simply scan A, and when it scans the pagebreak, it stores a local flag
clear_next(inlayout/mod.rs(docbuilder) and only notify the next page that, when it layout B it needs to insert a new page before B. However, problem arises when A and B uses different styles, the empty page would follow the style of the next page. Which is against intuition that the style of the empty page should be identical to previous page.Essentially, the first way to solve this problem is to introduce the pagebreak in the parsing and then look one step ahead; but that does not seem possible to add pagebreak as a syntax kind. Rather, we would do it when we parse into contents.
In order to do that, we first introduce a function API to access the last page, and we set a flag to notify the page to create an empty page after it. Note that there is a special case that someone would do a pagebreak first and then start the first page, to handle this special case, we add an extra routine to prepend an emtpy page.