Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Keep rule #8

Closed
teddybradford opened this issue Aug 5, 2017 · 6 comments
Closed

Keep rule #8

teddybradford opened this issue Aug 5, 2017 · 6 comments

Comments

@teddybradford
Copy link
Contributor

teddybradford commented Aug 5, 2017

It would be really awesome to have a keep rule that takes an array of selectors and tries to keep them together. For example: given [h1, p] if a break would normally occur after h1, bindery should try to avoid that break if the following element is p, and instead put the break before the h1 element.

@evnbr
Copy link
Owner

evnbr commented Aug 6, 2017

Yeah, I could certainly see the use for this. Before I figure out how to implement this, would any of these achieve the effect better or worse?

  1. CSS Regions had a break-after: avoid rule, which would be applied to one element, ie the h1 in your example.
  2. If the whole post was wrapped together, you could just apply PageBreak({ position: 'avoid' }), but that may not be clear.
  3. You could avoid the issue with PageBreak({ position: 'before' }), but I don't imagine that's the effect you wanted.

@teddybradford
Copy link
Contributor Author

I'm not sure those would really work for this.

I'm interested in parity with InDesign's keep options, though that seems like it would be pretty complicated to implement.

Just being able to set rules for keeping sibling elements together would go a long way, I think. It can be awkward for a heading to start at the end of a page, and I'm looking for a way to prevent that without inserting a full page break before each of the titles.

@teddybradford
Copy link
Contributor Author

Being able to select sibling wildcard (*) elements would be useful, too.
e.g., h1 + *

@evnbr
Copy link
Owner

evnbr commented Aug 8, 2017

Hmm, fair. I guess I'm trying to figure out why it has to depend on both elements. Are there situations where you have a heading style, and do want there to be a page break after it? Like [h2 + p] should stay together, but [h2 + figure] should not? (that seems unlikely but i am open to being convinced).

I'm considering whether it's worthwhile to mirror CSS proposal docs, ie https://developer.mozilla.org/en-US/docs/Web/CSS/break-after

@teddybradford
Copy link
Contributor Author

I think as long as PageBreak rules override the Keep rules, there is no need to be able to specify specific elements. For example, if there is a Keep rule created for h2 elements, and a PageBreak rule set to break before .gallery elements, then h2 + * would always be kept on the same page unless * is a .gallery.

@evnbr
Copy link
Owner

evnbr commented Jan 11, 2021

Closing to track in regionize repo

@evnbr evnbr closed this as completed Jan 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants