Skip to content

🐛 FIX: Honor empty rule lists in custom presets - #467

Open
anticipate218 wants to merge 1 commit into
executablebooks:masterfrom
anticipate218:fix/honor-empty-preset-rules
Open

anticipate218 wants to merge 1 commit into
executablebooks:masterfrom
anticipate218:fix/honor-empty-preset-rules

Conversation

@anticipate218

Copy link
Copy Markdown

An explicit empty rules list in a custom preset currently leaves every rule enabled. For example, copying the commonmark preset and setting components['inline']['rules'] = [] still renders emphasis and links. Python treats the empty list as false, whereas the upstream JavaScript check treats an empty array as present.

Check for None before applying rules or rules2, so an empty list reaches enableOnly and clears that chain. Omitted and None values keep the current behavior. Tests cover all four chains and literal inline rendering; documentation and the changelog describe the distinction.

Validation on Windows:

  • Both final regression tests fail on the unchanged implementation.
  • tox -e py313 with PYTHONUTF8=1: 1,192 passed on Python 3.13.9. Without UTF-8 mode, two pre-existing file-regression output fixtures raise encoding errors on this cp936 system; the same two failures reproduce on the original source.
  • Ruff lint/format pass; mypy 2.4.1 passes in the minimal hook environment with its default --ignore-missing-imports; applicable JSON/YAML/EOF/whitespace checks pass. Full pre-commit initialization failed while fetching the mypy mirror from GitHub.
  • Strict HTML documentation builds through tox with API generation enabled and the display-only post-build echo omitted because it is unavailable as an executable on Windows. No repository configuration was changed for these command overrides.
  • An independent review checked 256 missing/None/empty/single-rule combinations and three built-in preset controls.

Other Python versions/platforms, benchmarks, link checking and the separate plugin-repository test suite were not run.

AI assistance: Codex investigated and prepared the patch/tests; another agent independently reviewed the behavior and ran the configuration matrix.

Forward explicitly empty rules and rules2 lists to enableOnly so custom presets can disable an entire parser chain. Keep missing and None values unchanged; cover all four chains and literal inline rendering.

Assisted-by: OpenAI Codex

This branch has not been deployed

No deployments
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