-
Notifications
You must be signed in to change notification settings - Fork 2
全体コンパイルしたときと個別コンパイルした際の差異を修正 #32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses differences in behavior between compiling the entire project versus individual articles by introducing a centralized initialization mechanism with state tracking. Instead of each template file managing its own initialization, a new init.typ module tracks whether initialization has occurred using Typst's state management, preventing duplicate show rule applications.
- Introduced
template/init.typwith aninitialize()function that uses state to track initialization - Refactored
project.typandarticle.typto use the centralizedinitialize()function - Adjusted spacing values for headings and figures (doubled padding/margin values)
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| template/init.typ | New centralized initialization module with state tracking to prevent duplicate show rule applications |
| template/project.typ | Simplified by removing direct initialization logic and delegating to initialize() function |
| template/article.typ | Simplified by removing direct initialization logic and delegating to initialize() function |
| template/utils.typ | Increased spacing for headings (levels 1-4) and figures by doubling padding values |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| body | ||
| } | ||
|
|
||
| has-initialized-state.update(true) |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state update occurs after rendering the body, which causes initialization to happen multiple times in nested scenarios. When project.typ calls initialize and its body contains articles that also call initialize, the nested initialize calls will see the state as still false because the outer initialize hasn't updated it yet.
The state should be updated immediately after the check, before rendering the body. Move has-initialized-state.update(true) to line 9 (right after the context if line), so it executes before the show rules are applied and the body is rendered. This ensures nested calls to initialize will correctly see that initialization has already occurred.
| show: remove-cjk-break-space | ||
| show: page-setting | ||
| show: body-setting | ||
| show: codly-init |
Copilot
AI
Nov 11, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The call to codly-init on line 13 has been changed from show: codly-init.with() (as used in the original project.typ and article.typ) to show: codly-init without the .with() call.
If codly-init is a function that returns a show rule (rather than being a show rule itself), this change may cause incorrect behavior. Please verify that codly-init can be used directly as a show rule without calling .with() first. If the original .with() was necessary, it should be restored as show: codly-init.with().
| show: codly-init | |
| show: codly-init.with() |
Resolve: #27
いちいち処理を分けるのは面倒なので初期化されたかどうかの state を持つようにした