feat: paragraphize content blocks in script mode#24
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to properly handle content blocks in script mode by converting them to paragraph nodes in the textlint AST. The implementation introduces helper functions to flatten markup children and recursively convert Marked::ContentBlock nodes to Paragraph nodes.
Key changes:
- Added
flattenTypstMarkupChildrento recursively flatten markup/content block children while filtering out bracket delimiters - Added
convertScriptContentBlocksToParagraphsto transform content blocks into paragraph nodes - Enhanced
paragraphizeTextlintAstObjectwith hash statement detection logic to properly handle script-mode statements
Reviewed changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| src/typstToTextlintAst.ts | Core implementation: added utility functions for flattening markup children, converting content blocks to paragraphs, and detecting hash statements for proper paragraphization |
| test/unit/fixtures/loops/input.typ | Test fixture: Typst source with for/while loops containing content blocks |
| test/unit/fixtures/loops/output.json | Expected AST output for loops fixture with paragraphized content |
| test/unit/fixtures/content-blocks/input.typ | Test fixture: Typst source demonstrating script-mode content blocks with variables |
| test/unit/fixtures/content-blocks/output.json | Expected AST output for content blocks with proper paragraph wrapping |
| test/unit/fixtures/conditionals/input.typ | Test fixture: Typst conditional statements with content blocks |
| test/unit/fixtures/conditionals/output.json | Expected AST output for conditionals with paragraphized content |
| test/unit/fixtures/bindings-and-destructuring/input.typ | Test fixture: Complex destructuring patterns with content blocks |
| test/unit/fixtures/bindings-and-destructuring/output.json | Expected AST output for bindings with properly transformed paragraphs |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
No description provided.