Skip to content

Fix code review findings in the preprocessor - #17

Merged
cssho merged 1 commit into
masterfrom
review-fixes
Oct 26, 2026
Merged

cssho merged 1 commit into
masterfrom
review-fixes

Conversation

@cssho

@cssho cssho commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Fixes from the /code-review of v0.1.8...HEAD, before releasing 0.2.0.

Summary

  • Directives in code fences (regression from Match symbols as whole names and validate block structure #13): a docs page showing e.g. ```md + <!--- #else --> raised ConditionSyntaxError and aborted the whole MkDocs build (0.1.8 passed it through). Fences now form their own lenient scope:
    • complete #if … #endif blocks inside a fence still apply (conditional code samples, as in 0.1.x)
    • malformed directives inside a fence (#else/#endif without #if, nested #if, duplicate #else) stay as text
    • an #if still open when the fence closes is rolled back to verbatim text
    • fences follow CommonMark closing rules (same char, ≥ length); outside fences nothing changes (still strict)
  • YAML scalar symbols: symbol: 2024 / 1.5 / yes crashed with TypeError: 'int' object is not iterable; now stringified. False is no longer silently treated as "no symbols"
  • Error messages include the line text: MkDocs strips front matter before Markdown sees the page, so line N is offset; line 2: #endif without #if: '<!--- #endif -->' is findable regardless
  • README "Rules" updated

Test plan

  • uv run pytest — 50 passed (new tests/test_fences.py: verbatim cases incl. ~~~, longer fences, unterminated fence; conditional code samples; nested/duplicate in fence; outer block hiding a fence; errors outside fences still raise; YAML scalars; message text), also on Markdown 3.2 / py3.10
  • Real mkdocs build: fenced #else example renders as code, symbol: 2024 works, an error in a page with front matter reports the line text
  • ruff check / format clean
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_012pKTVb5TrGn27R29rHHNck

- Directives inside code fences get their own lenient scope: complete
  blocks still apply, but malformed directives (and an #if left open
  at the fence end) stay as text instead of raising. Docs that show
  md-condition syntax in a fence no longer break the build
- Accept YAML scalars as `symbol` (2024, 1.5, true) instead of
  crashing with TypeError; False is no longer treated as empty
- Include the offending line's text in ConditionSyntaxError, since
  line numbers are offset by MkDocs front matter

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pKTVb5TrGn27R29rHHNck
@cssho
cssho merged commit f6c87d8 into master Oct 26, 2026
8 checks passed
@cssho
cssho deleted the review-fixes branch October 26, 2026 13:13
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.

1 participant