Repository navigation
Conversation
Co-authored-by: nbolat <[email protected]>
…14-markdown-escaping
|
Warning Review limit reachedNext included review available in 25 seconds. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
|
|
@pullfrog Please review the current head, 7a1ddd3. The initial review is still running against 4f3b095. Since then, CI identified the existing large malformed-link paragraph regression; the size limit now preserves the existing paragraph/heading bracket path. All 368 rich-Markdown tests pass locally (2 skipped), along with renderer types and changed-code quality. |
There was a problem hiding this comment.
Important
The 50,000-code-unit block cap drops literal preservation for large blocks. That regresses the pre-existing rich-markdown-inline-source-tokenization test (a single ~112k-character paragraph) and re-introduces the excessive escaping #22014 reports for any block above the cap. Please resolve before merge (details inline).
Reviewed changes
- Nested blocks now participate —
LITERAL_BLOCK_TYPESaddsblockquote,bulletList,orderedList, andtaskList, so callouts and list bodies are unescaped and validated as whole containers (rich-markdown-literal-serialization.ts:7). This is the actual fix for the> [!NOTE]corruption in #22014. - Unicode-aware optional-escape stripping —
withoutOptionalEscapesconsumes escaped backslashes first and only strips\_runs flanked by\p{L}\p{N}\p{M}(rich-markdown-literal-serialization.ts:16), replacing the previous unconditional per-character strip. - Bounded reparse work — blocks over 50,000 code units skip validation, and unchanged candidates skip the parse entirely (
rich-markdown-literal-serialization.ts:6,:38,:46). - Broader definition bail-out — the document-wide guard now matches
]:anywhere rather than only line-start definitions (rich-markdown-literal-serialization.ts:71). - Tests — 25 new cases in
rich-markdown-escape-fidelity.test.tscovering intraword underscores, delimiter runs, nested containers, and the size boundary.
I independently fuzzed the cross-block property (~9k differential editor round-trips): the per-block eq check plus the doc-wide ]: guard hold up, and I found no input where an emitted candidate recombines into a different document or corrupts a transport envelope.
ℹ️ Nitpicks
- The document-wide
]:guard (rich-markdown-literal-serialization.ts:71) now bails on any]:anywhere, so ordinary prose such asuser_name [a]:bdisables preservation for the whole file and leavesuser\_nameescaped — broader than needed to catch the nested-definition case. Matching the definition shape (optional blockquote/list prefix, then[label]:) would keep the fix without over-bailing. keeps literal delimiter runs and backslashes safe(rich-markdown-escape-fidelity.test.ts:56) only asserts reopen equality, so it cannot distinguish a preserved-but-escaped output from the intended unescaped one. Asserting the exact expected string would actually pin the__init__/_word_behavior the test name claims.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Prior round (
4f3b095): broadenedLITERAL_BLOCK_TYPEStoblockquote/lists, madewithoutOptionalEscapesUnicode-aware and escaped-backslash-safe, added a 50,000-code-unit block cap, and widened the]:reference-definition guard. I flagged that the cap broke the pre-existingrich-markdown-inline-source-tokenizationlarge-paragraph test. - This round (
7a1ddd3): the cap now exemptsparagraph/headingblocks whose serialized markdown contains escaped brackets (rich-markdown-literal-serialization.ts:42), restoring the pre-PR large wiki-link paragraph path while still bounding the newly added nested-container and underscore-only validation.
I re-ran the full src/renderer/src/components/editor suite at 7a1ddd3: 1703 passed, 2 skipped, 0 failed — the previously failing large-paragraph test now passes. The preservesBrackets exemption is exactly the base guard's /\\[[\]]/ condition for paragraph/heading, so it restores existing behavior rather than opening a new path; no new correctness or safety concern. The prior review thread has been resolved.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Follow-up to the review of
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the full net diff at head 7a1ddd3 (no prior Pullfrog review exists on this PR, so the network was the two-file change set).
- Extended the literal-source preservation guard to intraword escaped underscores (Unicode-aware and intraword-only) and to nested
blockquote/list block types, replacing the old unconditional\_unescape with a stricter regex. - Bounded the expanded validation to blocks over 50,000 code units (
MAX_LITERAL_BLOCK_CODE_UNITS) while exemptingparagraph/headingblocks that contain escaped brackets, so long malformed-link prose keeps its established source fidelity. - Broadened the reference-definition early-out to
\][ \t]*:and added a per-block cache plus acandidate === markdownshort-circuit, withrich-markdown-escape-fidelity.test.tscovering Unicode identifiers, delimiter runs, nested containers, definitions, call caching, and the size cap.
The per-block parse-and-node-equality guard remains the safety net: unescaping is accepted only when reparsing the block reproduces the same node, so unsafe or unproven changes retain the canonical escaped output. The head commit's preservesBrackets bypass restores the pre-existing behavior for the dominant large-block path rather than opening a new one. Focused tests pass at head (rich-markdown-escape-fidelity, rich-markdown-literal-serialization, rich-markdown-inline-source-tokenization — 43 tests), and the existing rich-markdown-inline-source-tokenization.test.ts large malformed-link paragraph is the regression the head commit restores.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

ELI5
Editing rich Markdown keeps safe underscores and nested callouts readable in the saved source.
What Changed
Extend the existing literal-source preservation guard to Unicode intraword underscore runs and nested quote/list blocks. Each optional unescape is accepted only after reparsing produces the same editor node. Keep reference-like text conservative, bound the newly added validation to 50,000 code units per block and reuse the existing node cache. Preserve the existing large paragraph/heading bracket path, so long wiki-link prose keeps its established source fidelity.
Why
Removing escapes by regex alone can turn literal
__init__or___init___into emphasis on reopening. The existing parse-and-node-equality guard proves the saved syntax retains its meaning. Adapted from @nvimq #22123; attribution is preserved.Linked Issue
Related to #22014 and #22123. This covers safe underscores and nested callouts; it does not claim to preserve every source-formatting detail.
Visual Proof
Real hidden macOS Orca save/reopen flow in a folder workspace. Before/after saved source, baseline
b76bc79d73dand the same preservation change from the prior validation pass. Cropped to exclude local paths. Equality was checked from saved Source-to-Rich state to reopened state, not against an unsaved pre-serialization snapshot.Testing
Branch checks: all 368 rich-Markdown tests pass (2 skipped), including the existing large malformed-link paragraph regression; renderer types and changed-code quality pass. Prior full focused packet: 141 tests and hidden save/reopen checks passed; 11 regressions failed on baseline.
Review
Reviewed Unicode and escaped-backslash handling, delimiter runs, reference-definition interactions across blocks, raw HTML/code source ownership, bounded reparse work and cache invalidation. Unsafe or unproven changes retain the canonical escaped output.
Agent skill upstream boundary
Notes
Blank-line/final-newline normalization, other escape characters, definition-like/unsafe blocks and oversized blocks outside the existing paragraph/heading bracket path remain unchanged. The size cap and cache tests are not latency benchmarks. Local validation did not include native Windows/Linux/WSL, live SSH, mobile, the full suite or packaging. Required PR Checks and packaging passed in CI; the completed current-head Pullfrog review also reports 1,703 editor tests passed with two skipped. The additional full-diff Pullfrog review completed successfully at
7a1ddd397320with no new issues; its 43 focused tests also passed. On September 25, those 43 tests passed again locally, and a source/dependency compatibility review againstmain(85ac14e9c263) found no overlapping Markdown implementation changes or parser dependency changes. The branch remains mergeable without updating its source. Host-aware save routing and remote wire behavior are unchanged.Checklist