add support for nested style markdowns #3119
Merged
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.
Summary
Replaces regex-based markdown parsing with a character-by-character state machine to support nested and overlapping formatting like bold italic, bold nested italic text, and
strike italic through.Key Changes
applyTextFormatting.ts: Complete rewrite using state-driven parsing instead of regex splitting
applySegmentFormatting.ts: Enhanced to handle null returns from heading adjustment
adjustHeading.ts: Now returns null for empty segments after heading removal
Tests: Added comprehensive coverage for nested formatting scenarios
Features Added
✅ Nested formatting: text, bold italic bold
✅ Overlapping styles: italic bold italic
✅ Mixed formatting:
strike italic through✅ Proper state management with toggle-based formatting
✅ Edge case handling for marker-only inputs
Technical Improvements
Character-by-character parsing for better performance
Type-safe formatting state management
Original segment preservation when no formatting applied
Null-safe segment processing
Files changed: 3 core files + 5 test files with 334 insertions, 54 deletions