Skip to content

Support multiple defined symbols - #15

Merged
cssho merged 1 commit into
masterfrom
multiple-symbols
Oct 26, 2026
Merged

cssho merged 1 commit into
masterfrom
multiple-symbols

Conversation

@cssho

@cssho cssho commented Oct 26, 2026 •

Copy link
Copy Markdown
Owner

Closes #6

Summary

symbol can now define several symbols, each usable as its own condition (like -D flags in conditional compilation):

markdown_extensions:
  - md_condition:
      symbol: [DEBUG, RELEASE]   # or "DEBUG RELEASE" / "DEBUG|RELEASE"
  • #if A B / #if A | B is true when any defined symbol is among the listed names (exact-name matching from Match symbols as whole names and validate block structure #13 unchanged)
  • A single string symbol behaves exactly as before; None and [] define nothing (every #if false), same as an empty string
  • README "Rules" and MkDocs section updated

Thanks to @jmseguin for the request and @kamal-ahmed-maTha for the detailed spec in the issue thread — the tests use that example directly.

Test plan

  • uv run pytest — 32 passed, also on Markdown 3.2 / py3.10 (new: the Multiple Condition Symbols #6 example with space / | / list / tuple / single / empty / None configs, any-of matching, loading by name with a list)
  • End-to-end mkdocs build with symbol: [DEBUG, RELEASE] renders #if DEBUG, #else of #if STAGING, and #if RELEASE|STAGING correctly
  • ruff check / format clean
  • CI green

🤖 Generated with Claude Code

https://claude.ai/code/session_012pKTVb5TrGn27R29rHHNck

`symbol` now accepts several symbols: a string separated by spaces
and/or `|` ("DEBUG RELEASE", "DEBUG|RELEASE") or a list
(MkDocs: `symbol: [DEBUG, RELEASE]`). An `#if` is true when any
defined symbol is among its listed names. A single symbol behaves
exactly as before; None / [] define nothing.

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

Multiple Condition Symbols

1 participant