Skip to content

Keep numbering tokens literal inside inline code - #783

Open
mayankdhingra02 wants to merge 2 commits into
trentm:masterfrom
mayankdhingra02:codex/numbering-inline-code
Open

mayankdhingra02 wants to merge 2 commits into
trentm:masterfrom
mayankdhingra02:codex/numbering-inline-code

Conversation

@mayankdhingra02

Copy link
Copy Markdown

With the numbering extra, a literal caption example inside inline code is expanded into escaped <figcaption> markup and consumes a counter. The next real caption is then numbered incorrectly. Literal [@reference] examples are also rewritten.

Check numbering opener positions against the parser's code spans before evaluating the full caption or reference pattern. Both passes use the same interval scan; repeated incomplete literal openers cannot consume a later real caption or repeatedly rescan its suffix. Two new fixture groups cover forward references, multi-backtick spans, literal references and the existing fenced-code behavior. Ordinary caption and reference handling is preserved.

make testone (312 tests) and make testredos (12 cases) pass on CPython 3.10.13, 3.11.12, 3.12.9, 3.13.3 and 3.14.4 with all optional extras installed. Both new fixtures fail on the unchanged base. Wheel/sdist builds, Twine checks and installed-package checks pass. These are macOS arm64 checks; Linux and Windows CI are separate.

Unbackticked indented code blocks remain a known limitation. The current code-span recognizer is reused. Suggested note for the numbering wiki: caption definitions and references inside recognized inline code spans remain literal and do not affect counters.

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