-
Notifications
You must be signed in to change notification settings - Fork 0
Implement enhanced list builder with AST traversal and context-aware indentation handling #100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement enhanced list builder with AST traversal and context-aware indentation handling #100
Conversation
…builder Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
|
@copilot you seems cannot find correct test suite, they are under Tests/CodeParserCollectionTests/Markdown/Nodes. |
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
Thank you for pointing me to the correct test location! I found the tests at Tests/CodeParserCollectionTests/Markdown/Nodes and have been working on fixing the setext heading detection. I've identified the core issue: the setext heading builder runs in the Currently working on: 48a4835 The architecture is complex because setext headings need to be detected after regular line processing, since they require looking back at the previous paragraph. Still investigating the token processing flow. |
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
|
@copilot please continue iterate. If you find it is very difficult to do something, please check if you forget some thing like AST can be traverse and modified via context.current, you can use context.state to store intermediate states and trigger refresh rerun. |
I've identified the core issue with the setext heading detection! The problem is that the paragraph builder is processing the underline tokens before my setext heading builder can evaluate them properly. From debugging, I can see that for input The issue is with the token processing flow and state management. I need to better leverage Working on: e4526c0 |
…ts passing Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
|
@copilot , please continue iterate to fix the list issue. Please fully leverage the power of AST access and modification, and the context.state to maintain the level/indent info necessary for list construction. |
- Implement proper indentation-based list nesting detection - Add sophisticated context determination for nested vs sibling list items - Leverage AST traversal to find appropriate list containers - Utilize MarkdownConstructState.listStack for nesting level tracking - Fix marker compatibility logic for separate list creation - Improve from 12/26 to 14/26 list tests passing (53.8% success rate) - Core nested list functionality now works correctly Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
I've successfully implemented the list nesting logic as requested! The fix leverages AST access and modification along with context.state to maintain proper level/indent information. Key improvements implemented:
Results:
The implementation properly handles the CommonMark spec requirements for list nesting based on indentation relative to parent list item content indentation. Fixed in commit 49db6d1. |
|
@copilot could you continue refine the list build? We have list builder and list item builder which I think is not a great idea as list itself do not have any grammar, it is actually generated when list item created. I think lots of bugs and fix difficult is caused by this. Can we just have a MarkdownListBuilder to do the list create? |
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
I've implemented the unified MarkdownListBuilder approach as you suggested! You were absolutely right about the architectural issues. Changes Made (ad16c96):
Results:
The unified approach makes the code much cleaner and easier to debug. All list logic is now in one place, driven by list item marker detection as you suggested. Still working on some edge cases around paragraph continuation and indentation handling. |
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
|
@copilot from the iteration, seems the indent calculation and newline handling are challenges, could you consider leverage the AST traverse(have indent record and level info) and context.state to solve the issue? For line break handling, it cause lots of bugs, can you find a way to solve it? Please note, this branch is a WIP branch, you can do anything that follows best practices, do not worry about break something, just follow best practices. You can do the architectural change if necessary. |
I've implemented the enhanced AST traversal and state management approach as you requested! The key improvements include: AST Traversal & Context State Enhancements:
Indentation Calculation Fixes:
Newline/Blank Line Handling:
Results:
Still working on fine-tuning the paragraph continuation vs code block logic. The architectural improvements are working - deep nesting is now detected correctly! Commit: 4a7bc8d |
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
Co-authored-by: DongyuZhao <8455725+DongyuZhao@users.noreply.github.com>
Replaced the problematic dual-builder approach (MarkdownListBuilder + MarkdownListItemBuilder) with a comprehensive unified MarkdownUnifiedListBuilder that leverages AST traversal and enhanced state management to solve complex indentation and nesting challenges.
Key Architectural Improvements
AST Traversal & State Management:
ListContextInfoinMarkdownConstructStateto track indentation levels and nesting contextbuildListContextFromAST()for understanding current nesting positionlistContextStackfor proper indent/level tracking across complex hierarchiesContext-Aware Indentation Logic:
- bazwere treated as code blocksGrammar-Driven Design:
Results
The enhanced architecture successfully handles complex nesting scenarios like:
This now correctly produces three nested lists with proper paragraph separation instead of treating the structure as indented code blocks.
Example Fix
Before: Deep nesting failed entirely
After: Proper nested structure with paragraph continuation
The refactoring successfully addresses the core architectural issues while significantly improving functionality for complex list nesting scenarios.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.