Skip to content

馃憣 Add mapped token subtype for fence and HTML blocks - #431

Open
adamtheturtle wants to merge 2 commits into
executablebooks:masterfrom
adamtheturtle:feat/mapped-block-tokens
Open

adamtheturtle wants to merge 2 commits into
executablebooks:masterfrom
adamtheturtle:feat/mapped-block-tokens

Conversation

@adamtheturtle

@adamtheturtle adamtheturtle commented Sep 16, 2026

Copy link
Copy Markdown

Summary

Implements the mapped-token subtype approach for #430. MappedToken requires a source map at construction and types map as list[int]; ordinary Token.map remains optional. The built-in fence (including make_fence_rule variants) and HTML-block rules now emit it via StateBlock.push_mapped(). Plugins can opt in.

Consumers narrow with isinstance(token, MappedToken); checking token.type alone is not sound because token types are extensible. This change is deliberately scoped to the two built-in rules motivating #430, not every token that happens to have a map. Existing Token construction, serialization shape, and value equality remain compatible.

Validation

  • Python 3.10, 3.11, 3.12, and 3.13: 1,006 tests passed on each
  • mdit-py-plugins suite against this branch: 511 passed
  • pre-commit run --all-files: passed, including strict mypy
  • git diff --check: passed

The upstream GitHub Actions CI and fuzzing runs are awaiting maintainer approval for this fork PR. Local clean docs builds hit the pre-existing docs/conf.py use of sphinx.ext.apidoc.OPTIONS, which is absent in current Sphinx 8/9; the Read the Docs check is reported separately by GitHub.

@adamtheturtle
adamtheturtle marked this pull request as ready for review September 16, 2026 14:04
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