Skip to content

Expand admonition support from warning-only to multiple types#11

Merged
samuelduchesne merged 2 commits intomainfrom
claude/add-admonition-types-uKicx
Feb 26, 2026
Merged

Expand admonition support from warning-only to multiple types#11
samuelduchesne merged 2 commits intomainfrom
claude/add-admonition-types-uKicx

Conversation

@samuelduchesne
Copy link
Copy Markdown
Contributor

Summary

Extended the admonition conversion system to support multiple admonition types beyond just warnings. The LaTeX preprocessor now handles 8 different admonition macros (\warning{}, \caution{}, \important{}, \tip{}, \note{}, \example{}, \seealso{}, \limitation{}), each mapping to appropriate Zensical admonition types with display titles.

Key Changes

LaTeX Preprocessor (scripts/latex_preprocessor.py)

  • Replaced single convert_warning_macro() function with generalized convert_admonition_macros() function
  • Added _ADMONITION_MACROS dictionary mapping LaTeX macro names to bold-prefixed labels
  • All 8 admonition macros now convert to \begin{quote} blocks with \textbf{<Type>:} prefixes
  • Updated preprocessing pipeline to call the new unified function

Pandoc Lua Filter (scripts/pandoc_filters/energyplus.lua)

  • Created ADMONITION_MAP table with 8 entries, each specifying:
    • Lua pattern to detect the bold prefix in blockquote content
    • Strip pattern to remove the prefix from output
    • Target Zensical admonition type
    • Display title for the admonition
  • Refactored BlockQuote() function to iterate through the mapping table instead of hardcoding warning detection
  • Updated admonition output to include display titles: !!! <type> "<title>" instead of !!! <type> ""
  • Entries ordered by length (longest first) to prevent partial pattern matches

Implementation Details

  • The two-stage conversion (LaTeX → quote with bold prefix → Zensical admonition) allows the Lua filter to determine admonition type based on content inspection
  • Display titles are preserved in the final admonition output for better documentation clarity
  • The mapping is extensible: new admonition types can be added by updating both the preprocessor dictionary and Lua filter table

https://claude.ai/code/session_01EC6b95DksGwS61813obV4g

@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

github-actions Bot added a commit that referenced this pull request Feb 26, 2026
@github-actions
Copy link
Copy Markdown
Contributor

Docs preview for this PR is available at:
https://docs.idfkit.com/pr-preview/pr-11/

github-actions Bot added a commit that referenced this pull request Feb 26, 2026
Extend the LaTeX→Markdown→Zensical pipeline from 2 admonition types (note,
warning) to 8 by detecting bold-text prefixes in blockquotes and mapping them
to distinct Zensical types with proper titles:

  - **Warning:** → !!! warning "Warning"
  - **Caution:** → !!! danger "Caution"
  - **Important:** → !!! info "Important"
  - **Tip:** → !!! tip "Tip"
  - **Note:** → !!! note "Note"
  - **Example:** → !!! example "Example"
  - **See Also:** → !!! abstract "See Also"
  - **Limitation:** → !!! failure "Limitation"

Lua filter: replace single if/else with data-driven ADMONITION_MAP table.
Preprocessor: generalize \warning{} into convert_admonition_macros() handling
8 LaTeX macros (\warning, \caution, \important, \tip, \note, \example,
\seealso, \limitation).

https://claude.ai/code/session_01EC6b95DksGwS61813obV4g
Add three new preprocessing steps that activate the admonition type system
for content that actually exists in the EnergyPlus docs:

1. normalize_bold_prefix_colons: Fix \textbf{Note}: (colon outside braces)
   to \textbf{Note:} so the Lua filter can match it (7 occurrences)

2. promote_callout_prefixes: Convert plain-text "Note:", "NOTE:", "Caution:"
   at the start of callout bodies to \textbf{Note:} etc. so they become
   typed admonitions instead of generic notes (~28 occurrences). Requires
   a colon after the keyword to avoid false positives like "Note that..."

3. wrap_standalone_bold_admonitions: Wrap standalone \textbf{Note:} paragraphs
   (not inside any callout/quote env) in \begin{quote}...\end{quote} so the
   Lua filter's BlockQuote handler can process them (20 occurrences)

Together these activate ~55 existing admonition-like patterns in the source
that were previously rendered as plain text or generic untitled notes.

https://claude.ai/code/session_01EC6b95DksGwS61813obV4g
@samuelduchesne samuelduchesne force-pushed the claude/add-admonition-types-uKicx branch from 54b7edb to ffb269b Compare February 26, 2026 15:42
github-actions Bot added a commit that referenced this pull request Feb 26, 2026
@samuelduchesne samuelduchesne merged commit 36a73d7 into main Feb 26, 2026
4 checks passed
@samuelduchesne samuelduchesne deleted the claude/add-admonition-types-uKicx branch February 26, 2026 16:11
github-actions Bot added a commit that referenced this pull request Feb 26, 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.

2 participants