Repository navigation
https://github.com/jackdewinter/pymarkdown/issues/1679 - #1695
Conversation
Reviewer's GuideFix GFM parsing regressions around table continuation and list items containing pipe characters by making parser stack/document requeue cleanup token-aware, preventing an unsafe list-token replacement, and adding extensive regression tests across surrounding block constructs. Sequence diagram for token-aware table requeue cleanupsequenceDiagram
participant TableProcessor
participant ParserState
participant TokenStack
participant TokenDocument
TableProcessor->>ParserState: process_table_rows(...)
TableProcessor->>TableProcessor: __prepare_for_requeue_reset_document_and_stack(...)
TableProcessor->>TokenStack: Remove tokens beyond original_stack_depth
alt stack was cleared below original depth
TableProcessor->>TokenStack: Restore copy_of_token_stack
TableProcessor->>TokenDocument: Remove trailing non-block-quote tokens
else matching token was removed
TableProcessor->>TokenDocument: Remove tokens through last_removed_token
end
TableProcessor-->>ParserState: Requeue with synchronized stack and document
Sequence diagram for safe list-item replacementsequenceDiagram
participant ListHandler
participant ParserState
participant TokenDocument
ListHandler->>ParserState: __post_list_use_new_list_item(...)
ListHandler->>TokenDocument: Check final token with is_list_start
alt top-level list already ends with a list-start token
ListHandler-->>ListHandler: Return without replacement
else replacement is safe
ListHandler->>ListHandler: Create NewListItemMarkdownToken
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've found 1 issue
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location path="pymarkdown/general/parser_state.py" line_range="411-417" />
<code_context>
False,
)
+ POGGER.debug(f"self.token_stack = {self.token_stack}")
+ POGGER.debug(
+ f"parser_state.original_stack_depth = {self.__original_stack_depth}"
+ )
+ POGGER.debug(f"self.token_document = {self.token_document}")
+ POGGER.debug(
+ f"parser_state.original_document_depth, = {self.__original_document_depth}"
+ )
+
</code_context>
<issue_to_address>
**nitpick (performance):** The new debug calls eagerly interpolate complete parser stacks and token documents into f-strings even when debug logging is disabled. Every parsed line therefore pays the cost of constructing potentially large string representations, degrading parser performance on large documents.
**Triggers:** During normal parsing with debug logging disabled, especially for documents with large token stacks or token documents.
**Suggested fix:** Use the logger's deferred `$` substitution interface instead of f-string interpolation.
</issue_to_address>| POGGER.debug(f"self.token_stack = {self.token_stack}") | ||
| POGGER.debug( | ||
| f"parser_state.original_stack_depth = {self.__original_stack_depth}" | ||
| ) | ||
| POGGER.debug(f"self.token_document = {self.token_document}") | ||
| POGGER.debug( | ||
| f"parser_state.original_document_depth, = {self.__original_document_depth}" |
There was a problem hiding this comment.
nitpick (performance): The new debug calls eagerly interpolate complete parser stacks and token documents into f-strings even when debug logging is disabled. Every parsed line therefore pays the cost of constructing potentially large string representations, degrading parser performance on large documents.
Triggers: During normal parsing with debug logging disabled, especially for documents with large token stacks or token documents.
Suggested fix: Use the logger's deferred $ substitution interface instead of f-string interpolation.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1695 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 205 205
Lines 25026 25056 +30
Branches 3127 3130 +3
=========================================
+ Hits 25026 25056 +30 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Summary by Sourcery
Fix block parsing so table-like and link-reference list content is handled as ordinary list items without disrupting surrounding Markdown.
Bug Fixes:
Enhancements:
Documentation:
Tests: