Skip to content

Conversation

@Ryoga-exe
Copy link
Member

@Ryoga-exe Ryoga-exe commented Sep 25, 2025

Resolve: #27

いちいち処理を分けるのは面倒なので初期化されたかどうかの state を持つようにした

Copy link

Copilot AI left a 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.typ with an initialize() function that uses state to track initialization
  • Refactored project.typ and article.typ to use the centralized initialize() 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)
Copy link

Copilot AI Nov 11, 2025

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.

Copilot uses AI. Check for mistakes.
show: remove-cjk-break-space
show: page-setting
show: body-setting
show: codly-init
Copy link

Copilot AI Nov 11, 2025

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().

Suggested change
show: codly-init
show: codly-init.with()

Copilot uses AI. Check for mistakes.
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.

全体コンパイルしたときと個別コンパイルしたときで組版結果が微妙に違う?

2 participants