Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a processor takes one line off a block and returns the rest, every block processor tests the rest again.
HashHeaderProcessor.testandAdmonitionProcessor.testrun a regular expression starting with(?:^|\n)over the whole remainder each time, which is slow because the regex has no literal prefix to search for. Tight headers, tight changelogs and Setext headers with no blank lines between them pay this once per line.This checks for a line starting with
#(or for!!!) with a plain substring test before running the regex. The regex needs that text to match, so the result is the same.SetextHeaderProcessor.runalso splits only the first two lines instead of splitting the whole block and joining it back.Median of 5 alternating runs in one process, CPython 3.14, extensions
toc,tables,fenced_code,admonition,attr_list,footnotes,def_list,abbrandmd_in_html:The old and new code give the same HTML on 30,000 generated documents mixing headers, admonitions, tables, lists and other blocks.
AI Assistance Disclosure
No AI tools were used in preparing this PR.
AI tools were used and I have disclosed which ones, and have fully reviewed and verified their output.
Claude Code (Claude Opus 5.5) was used for everything ticked below. The review attestation in the box above is left for the human submitter.
AI tools were use to assist with the following:
Checklist