Migrate orga from v2 to v4#837
Open
fenril058 wants to merge 25 commits into
Open
Conversation
Use an `interface` instead of a `type`
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
…ne/newline nodes traverse.remove() misses the last element when multiple consecutive removals occur (its index adjustment compensates by only one step per removal). Strip emptyLine and newline tokens with a recursive children filter after the traversal loop instead. Also restores correct orga v4 type mapping: inline text nodes use type "text" with a style property, not "text.plain"/"text.bold" etc., and link URLs live in node.path.value. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
orga v4 produces a unist-compatible AST, so use the standard unist-util-visit for tree traversal instead of the generic traverse library. This removes the this.notLeaf guard (unist-util-visit only descends into children arrays, never into data objects or other non-node properties) and eliminates the traverse dependency entirely. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
orga v4 wraps each headline and its content in a section node (document > section > [headline, paragraph, section, ...]). TxtAST has no equivalent for section, so promote section children directly into the parent, giving the flat structure that textlint rules expect (document > [header, paragraph, header, paragraph]). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…nd headings Covers the case where newline nodes were left with range=undefined due to traverse.remove() missing the last consecutive removal, which caused TypeError in rules using sentence-splitter (e.g. textlint-rule-sentence-length). Uses @textlint/ast-tester to assert every node has valid range/loc/raw. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…, and AST validity Add mapping for strikeThrough → Delete (orga v4 style property). New unit tests (OrgProcessor-test.ts): - italic, verbatim, strikeThrough inline styles - inline footnote reference ([fn:1] inside paragraph) - nested list structure (outer/inner List and ListItem nodes) - Str node range, loc, and raw values against source text New AST validity tests (ast-test.ts, using @textlint/ast-tester): - all inline styles in one paragraph - nested list - link with description - inline footnote reference Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…ation OrgProcessor unit tests: - availableExtensions returns ['.org'] - postProcess passes through messages and filePath - postProcess defaults filePath to '<org>' when not provided Edge cases: - empty string parses to empty Document without crashing - link without description extracts url correctly - ordered list produces List and ListItem nodes Header range after section flattening: - raw, range, and loc are correct for a heading preceded by section wrapper - sibling paragraph follows directly with no UNKNOWN section node between them Also adds empty string and ordered list to ast-tester validity suite. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Summary
(https://github.com/syntax-tree/unist)
(Document > [Header, Paragraph, Header, Paragraph, ...])
.eslintrc.jsto flat config (eslint.config.mjs)Background
orga v4 wraps each headline and its body in a
sectionnode:document > section > [headline, paragraph, ...]
TxtAST has no equivalent
sectionnode, so this PR promotes section children into the parent node before returning the AST.This preserves the flat structure expected by existing textlint rules.
Test plan
npm testpasses.orgfiles parse correctly with textlint rules (no regressions)