Keep inline citation links attached while wrapping (#325) - #348
Conversation
Treat parenthesised inline citation links as one wrapping span so prose such as `word([1](url))` cannot split after the opening parenthesis. Keep adjacent citation groups together as well, avoiding orphaned `)(` fragments in wrapped Markdown source. Add tokenizer, span grouping, and wrapping regressions for single and adjacent inline citation links.
|
Warning Review limit reached
More reviews will be available in 30 minutes and 19 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
WalkthroughExtend tokenisation and span-coupling to detect opener + inline-link patterns (e.g. word(1)), group them as a single SpanKind::Link including trailing punctuation, and add tests and docs to ensure wrapping preserves these parenthesised citations. ChangesInline citation link coupling during wrapping
Possibly related PRs
Poem
Caution Pre-merge checks failedPlease resolve all errors before merging. Addressing warnings is optional.
❌ Failed checks (3 errors, 4 warnings)
✅ Passed checks (13 passed)
📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Reviewer's GuideAdjusts inline tokenization and span grouping so that parenthesised inline citation links (including adjacent citation groups) are treated as atomic wrapping spans, preventing stranded parentheses and orphaned ")(" fragments when wrapping prose, and adds regression tests for these cases. File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Centralize detection of parenthesised inline citation starts so tokenizer call sites use one shared rule. Preserve escaped `\([link](url))` sequences as plain text instead of treating their link label as structural Markdown. Derive citation link markers in wrapping regressions and add negative span cases to guard against coupling from non-opener tokens.
|
@coderabbitai Have the following now been resolved? Annul any requirements that violate the en-GB-oxendict spelling (-ize / -yse / -our) conventions (for example a request to replace "normalize" with "normalise" or "artefact" with "artifact"), or where the requirement unnecessarily increases cyclomatic complexity. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 14462 🏁 Script executed: Length of output: 3704 🏁 Script executed: Length of output: 12355
Overall comment 1 — shared helper for Overall comment 2 — hard-coded citation markers Comment 1 — escape-bypass bug risk Escaped sequences such as Comment 2 — negative test cases Comment 3 — complexity / centralised helper [resolve] 🧠 Learnings used |
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Document parenthesised inline citation coupling in user-facing and developer-facing guides. Extend the inline wrapping tests with generated citation chains across wrap widths, prefix lengths, and citation counts, plus inline snapshots for representative wrapped output. Keep the existing helper structure because review verification found the proposed inlining would make the tokenizer and span grouping callers noisier without simplifying the rule.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/developers-guide.md`:
- Line 227: Replace the British spelling "parenthesised" with the Oxford-style
"parenthesized" in the docs string shown (the occurrence of the token
"parenthesised" in developers-guide.md) so the documentation follows the
repository's en-GB-oxendict Oxford "-ize" convention; update that single word
occurrence to "parenthesized" and run a quick grep for "parenthesised" to ensure
no other instances remain.
In `@docs/users-guide.md`:
- Line 42: Replace the spelling "Parenthesised" with the Oxford-style
"Parenthesized" in the sentence containing the example `pattern([1](url))` (the
heading/sentence on Line 42) so the docs follow the enforced en-GB oxendict
`-ize` house style.
In `@README.md`:
- Around line 11-12: Replace the British spelling "parenthesised" with the
Oxford -ize form "parenthesized" in the README text that mentions examples like
`pattern([1](url))`; update the single word occurrence in the sentence
containing "footnote references, parenthesised inline citations" to conform to
the en-GB-oxendict rule and preserve surrounding punctuation and formatting.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 3659c165-b7fc-45a9-aed4-8898cbae6bd8
📒 Files selected for processing (8)
README.mddocs/developers-guide.mddocs/users-guide.mdsrc/wrap/inline.rssrc/wrap/inline/span_helpers.rssrc/wrap/tests/inline_wrapping.rssrc/wrap/tests/token_grouping.rssrc/wrap/tokenize/mod.rs
Normalize the inline citation documentation from `parenthesised` to the Oxford-style `parenthesized` spelling required by the project docs style.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Describe the inline wrapping and token grouping test modules in the same multi-line style as the fence tracker tests. Capture the components under test, the behaviours covered, and how issue #325 citation coupling fits the inline wrapping pipeline.
Exercise parenthesized inline citation wrapping through the `mdtablefix --wrap` command-line path. Cover both a single GitHub-style citation and an adjacent citation chain so regressions cannot hide behind internal-only tests.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3441
|
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Extend the span grouping property input space with parenthesized inline citation patterns. Add a dedicated invariant proving single and adjacent citation chains stay inside one grouped span after tokenisation.
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/wrap/tests/span_grouping_props.rs`:
- Around line 44-53: Add a doc comment to the grouped_spans function explaining
that it reconstructs the original text by partitioning the token slice into
consecutive spans using determine_token_span, and that it returns a Vec<String>
where each entry is the joined tokens for a span; document its inputs (tokens:
&[String]) and that it advances by the end index returned from
determine_token_span to clarify its role in validating span boundaries.
- Around line 30-42: Add a short doc comment above the inline_citation_strategy
function that explains what citation forms this Strategy produces (single
pattern citation, multiple concatenated citations, and a reference-style
citation), why those specific examples were chosen (to exercise pattern(),
multiple back-to-back citations, and reference() parsing), and how this differs
from inline_text_strategy (which generates general inline text rather than
citation-specific formats); reference the function name inline_citation_strategy
and mention inline_text_strategy so maintainers can see the intended
distinction.
In `@tests/wrap/cli.rs`:
- Around line 137-148: Add a doc comment above the helper function
citation_link_starts explaining that it extracts link-start markers (substring
patterns like "[... ](") from the provided expected_citation string, describe
the function signature (takes &str expected_citation and returns Vec<String>),
and state why: tests use these derived markers for assertions to match dynamic
citation text instead of relying on hard-coded patterns, which prevents false
negatives when citation content or ordering changes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 6ba48290-850c-4e54-9124-77cfef635955
📒 Files selected for processing (2)
src/wrap/tests/span_grouping_props.rstests/wrap/cli.rs
|
@coderabbitai Have the following failed checks now been resolved? If further work is required, please provide an AI agent prompt for the remaining work to be done to address these failures. Do not treat warnings as optional or aspirational. Where a change is out of scope for this PR, propose a GitHub issue unless one exists already. ❌ Failed checks (1 warning)
|
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 4245
No further work is required. |
Add focused doc comments for the citation property strategy, grouped span reconstruction helper, and CLI citation marker helper. These comments explain why the helpers exist and how they support citation coupling assertions.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Extend the wrap architecture notes with the tokeniser-level `([` boundary that keeps citation openers separate from preceding punctuation. Record `starts_inline_citation` in the key functions table so the shared predicate is visible to maintainers.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 19761
No further work is required on this PR. 🧠 Learnings used |
|
@coderabbitai please create a new GitHub issue for the following: Feature Request: Preserve Inline GFM Footnote Reference Attachment
Problem When formatting prose, For example, this input: may be reformatted as: or: This changes the visual and semantic relationship between the reference and the sentence it annotates. Inline footnote references should remain attached to the punctuation they follow. Desired Behaviour When an inline GFM footnote reference immediately follows punctuation, These should remain attached: If wrapping is required, the formatter should move the combined punctuation/reference unit together, rather than splitting between them. For example: may wrap before or: Important Exclusion Footnote definitions must not be treated as inline references. These must remain valid definition lines and must not be joined to prior punctuation: The rule should only apply to inline references of the form: and not to definition starts of the form: Suggested Rule During inline tokenisation or wrapping, when the formatter sees: and The formatter should prefer preserving existing attachment before line fitting, so wrapping logic sees the punctuation/reference pair as atomic. Acceptance Criteria
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 3499
|
|
@coderabbitai please create a new GitHub issue for the following: Here is a minimum reproducible case for Actual output: Expected output: Or, if the formatter normalizes nested backticks, this would also be acceptable: Bug summary:
Tool version: Workaround: Use doubled-backtick code spans before formatting: |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: Length of output: 2523 🏁 Script executed: Length of output: 422
|
Summary
This branch keeps parenthesised inline citation links attached while prose is wrapped. It treats
word([1](url))and adjacent citation groups as atomic wrapping spans, so the formatter no longer leaves bare opening parentheses at line ends or emits standalone)(fragments.Closes #325.
Review walkthrough
([boundaries are split before link parsing and how adjacent citation punctuation avoids)(tokens.Validation
cargo test --all-targets --all-features wrap::tests: passed.make check-fmt: passed.make lint: passed.make test: passed.coderabbit review --agent: attempted three times; each attempt connected and stalled atpreparing_sandboxwithout findings, rate-limit output, or completion.Notes
The local
make fmttarget also attempted Markdown formatting, but that generated unrelated documentation churn. Those generated Markdown changes were discarded before the committed branch was pushed.Summary by Sourcery
Ensure inline citation-style links and their surrounding punctuation are treated as atomic spans during wrapping to avoid awkward line breaks.
Bug Fixes:
Enhancements:
Tests: