Skip to content

Avoid adding blank page with weak pagebreak when page is visually empty - #1500

Closed
azerupi wants to merge 2 commits into
typst:mainfrom
azerupi:prevent-weak-pagebreak
Closed

azerupi wants to merge 2 commits into
typst:mainfrom
azerupi:prevent-weak-pagebreak

Conversation

@azerupi

@azerupi azerupi commented Jun 14, 2023

Copy link
Copy Markdown
Contributor

Attempt to fix #1346

This PR seems to fix the problem I have and still pass the tests. I'm absolutely not sure that this has no other side-effects though.

If this looks good and doesn't have side-effects, I should probably add a test for this so that this behavior does not disappear in a future refactoring.

@Dherse

Dherse commented Jun 14, 2023

Copy link
Copy Markdown
Contributor

That's awesome, I had tried my hand at fixing it a couple of weeks ago, didn't think it would be so simple 🎉

@PgBiel

PgBiel commented Jun 15, 2023

Copy link
Copy Markdown
Contributor

I should probably add a test for this so that this behavior does not disappear in a future refactoring.

Please do (add a test), so we can ensure the code in the PR is working as expected.

@laurmaedje

Copy link
Copy Markdown
Member

There are other ignorant items like place. This PR might create problem with weak pagebreaks in combination with them.

@PgBiel

PgBiel commented Jun 20, 2023

Copy link
Copy Markdown
Contributor

There are other ignorant items like place. This PR might create problem with weak pagebreaks in combination with them.

Perhaps we could have some separate behavior type for content which is not intended to be actually displayed, such as counter(...).update(...)?

@azerupi

azerupi commented Jun 21, 2023

Copy link
Copy Markdown
Contributor Author

The elements I found that are marked as ignorant are

  • h and v
    What should happen if we have one or more h and v without other content on a page followed by a weak pagebreak?
    From my perspective, intuitively it would make sense to not make a new page and remove the spacing. But that might not be consistent behavior.

  • place
    place elements should probably always be show and a weak pagebreak should force a new page? Is it possible to place an element on each page with a show rule? If that is possible we might have someone trying to place an element on each page and having "blank" pages with weak pagebreaks.

  • meta
    meta isn't visible. A weak pagebreak should not create a new page. Right?

@laurmaedje

Copy link
Copy Markdown
Member
  • h and v: I'm on the fence, but tend to agree with you since they are also collapsed at the end of a page
  • place: I agree that it must be retained, on a separate page.
  • meta: Should not force a separate page, but must still be carefully retained for introspection to work correctly

@Beiri22

Beiri22 commented Jun 30, 2023

Copy link
Copy Markdown
Contributor

Is there any progress on this discussion / topic? I'm just curious because setting some metadata as state at the document start introduces an empty page. I could avoid finding a workaround if this PR advances.

@azerupi

azerupi commented Jun 30, 2023

Copy link
Copy Markdown
Contributor Author

I'm still looking into it, but haven't had much time. If anyone wants has ideas on how to implement it or help, please do.

@laurmaedje
laurmaedje marked this pull request as draft July 5, 2023 09:28
@Beiri22

Beiri22 commented Jul 14, 2023

Copy link
Copy Markdown
Contributor

The elements I found that are marked as ignorant are

  • h and v
    What should happen if we have one or more h and v without other content on a page followed by a weak pagebreak?
    From my perspective, intuitively it would make sense to not make a new page and remove the spacing. But that might not be consistent behavior.
  • place
    place elements should probably always be show and a weak pagebreak should force a new page? Is it possible to place an element on each page with a show rule? If that is possible we might have someone trying to place an element on each page and having "blank" pages with weak pagebreaks.
  • meta
    meta isn't visible. A weak pagebreak should not create a new page. Right?

h and v: i would agree as they collapse
place: could be parametrized as weak or not

@Beiri22

Beiri22 commented Jul 18, 2023

Copy link
Copy Markdown
Contributor

any news?

@laurmaedje laurmaedje added the waiting-on-design This PR or issue is blocked by design work. label Aug 8, 2023
@Beiri22

Beiri22 commented Aug 11, 2023 •

Copy link
Copy Markdown
Contributor

Perhaps we could have some separate behavior type for content which is not intended to be actually displayed

As it is an enum, you could just add a parameter to the Ignorant variant to get Ignorant(bool). Ignorant(true) could be an element that does not interact at all with other elements, but beeing visible. Ignorant(false) would then be an element that is not even visible. Elements that are definitely invisible like the Counter and State update functions, Metadata element, ... could be set to Ignorant(false) without hassle. The elements you are inconclusive about, could stay at Ignorant(true), and may later be changed or parametrized with some named argument to allow the user to change behaviour.

  • h and v: Ignorant(false)
  • place: would be a good candidate to allow the user to choose
  • meta and metadata: should be Ignorant(false)

What do you think? @azerupi and @laurmaedje and @PgBiel

@laurmaedje

Copy link
Copy Markdown
Member

Superseded by #1929 (which is merged now).

@laurmaedje laurmaedje closed this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

waiting-on-design This PR or issue is blocked by design work.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

weak pagebreak after page counter update always adds pagebreak

5 participants