Skip to content

Fix document set rules - #4768

Merged
laurmaedje merged 4 commits into
mainfrom
fix-document-set-rules
Aug 16, 2024
Merged

laurmaedje merged 4 commits into
mainfrom
fix-document-set-rules

Conversation

@laurmaedje

@laurmaedje laurmaedje commented Aug 16, 2024 •

Copy link
Copy Markdown
Member

This fixes the flakiness of document set rules by changing their semantics to deviate a bit from normal set rule semantics. Instead of being an immutable operation that just passes down information, document set rules are now basically naive setters that really just mutate the relevant piece of document information.

This means that

  • the information is not lost for an empty document
  • they can trivially depend on context
  • we get rid of the "document set rules must appear before any content" error

Overall, this makes them less error-prone to use and since the document information is a singleton anyway, I think we don't lose much through them working a bit differently (i.e. not being scoped). Note that document set rules are still only allowed at the top-level, not within layout containers.

This also adds a mechanism for adding special checks for specific tests, so that we can test that the document information is indeed correctly collected.

Fixes #2710
Fixes #4065
Fixes #4769

This fixes the flakiness of document set rules by changing their semantics to deviate a bit from normal set rule semantics. Instead of being an immutable operation that just passes down information, document set rules are now basically naive setters that really just mutate the relevant piece of document information.

This means that
- the information is not lost for an empty document
- they can trivially depend on context
- we get rid of the "document set rules must appear before any content" error

Overall, this makes them less error-prone to use and since the document information is a singleton anyway, I think we don't lose much through them working a bit differently (i.e. not being scoped). Note that document set rules are still only allowed at the top-level, not within layout containers.

This also adds a mechanism for adding special checks for specific tests, so that we can test that the document information is indeed correctly collected.

Fixes #2710
Fixes #4065
@laurmaedje
laurmaedje added this pull request to the merge queue Aug 16, 2024
Merged via the queue into main with commit d97d719 Aug 16, 2024
@laurmaedje laurmaedje mentioned this pull request Aug 16, 2024
1 task done
@laurmaedje
laurmaedje deleted the fix-document-set-rules branch August 16, 2024 11:01
@Andrew15-5

Copy link
Copy Markdown
Contributor

Huge! Now I don't need a separate show: set-document call inside show: it => { if ... { return ... } ... }, because I can use it inside context and if statement!

Now the only thing left to do is fix #2326 so that I can say the same thing about show: set-page. After that, everything (well, except for the #1097) can be simplified into a single function (with if statements): #4502. Multiple exact same bibliography calls isn't strictly necessary as I can use another workaround, but it would've been much easier to call the bibliography with the same argument however many times (requires 1 LoC instead of complex workarounds) and not have the error (I have show bibliography: none due to custom bibliography logic).

Dikluwe pushed a commit to Dikluwe/typst-crystalline that referenced this pull request Sep 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Set document conditionally Can't set document properties based on context Documents without content discard rules

2 participants