Preserve inline GFM footnote reference attachment (#353) - #355
Conversation
Normalize whitespace between sentence punctuation and immediately following GFM footnote references before inline wrapping. Keep footnote definitions excluded so definition lines remain structurally independent. Add unit, wrap, snapshot, and CLI regressions for same-line spacing, split references, indented split references, punctuation variants, and definition exclusion.
9ad5865 to
86eaef0
Compare
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughApply a new inline-token normaliser that removes whitespace between sentence-ending punctuation and immediately following GFM inline footnote references, integrate it into ChangesInline GFM Footnote Reference Attachment Normalisation
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 19 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (19 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. 📋 Issue PlannerBuilt with CodeRabbit's Coding Plans for faster development and fewer bugs. View plan used: ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Add user and developer documentation for punctuation-attached inline GFM footnote references and the normalisation pass that preserves them. Cover the normaliser with property tests for token preservation, matched spacing removal, definition exclusion, generated pattern handling, and idempotence. Exclude already parsed footnote reference tokens from the preceding-punctuation match so repeated normalisation cannot join adjacent references.
|
@coderabbitai review |
✅ Action performedReview finished.
|
Rename the spacing predicate so it describes the matched pattern directly. Return a borrowed token slice when no collapsible footnote spacing exists, avoiding an unconditional clone of every paragraph token stream.
|
@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 (3 warnings)
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
# Check 1: users-guide.md for footnote+punctuation documentation
echo "=== users-guide.md (footnote-related sections) ==="
fd -i 'users-guide.md' --exec grep -n -i 'footnote\|punctuation\|unbreakable\|attached' {}
# Check 2: developers-guide.md for normalize_footnote_ref_spacing entry
echo ""
echo "=== developers-guide.md (normalize / footnote sections) ==="
fd -i 'developers-guide.md' --exec grep -n -i 'normalize\|footnote' {}
# Check 3: proptest usage in normalize.rs or footnote test files
echo ""
echo "=== proptest in normalize.rs ==="
fd -e rs --exec grep -l 'proptest' {} | head -20
echo ""
echo "=== src/wrap/inline/normalize.rs contents ==="
fd -e rs -p 'normalize' --exec cat {}
echo ""
echo "=== tests/wrap_unit/footnotes.rs (check for proptest) ==="
fd -e rs -p 'footnotes' --exec grep -n 'proptest\|prop_' {}Length of output: 16100
No further work is required on these items. |
|
@coderabbitai review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 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/users-guide.md`:
- Line 86: Replace the British spelling "normalised" with the Oxford -ize form
"normalized" in the sentence fragment that reads "or `Sentence.` followed by
`[^ref]` is normalised back to `Sentence.[^ref]`" so the line becomes consistent
with the en-GB-oxendict `-ize` style rule.
In `@tests/wrap_unit/footnotes.rs`:
- Around line 89-95: The test constructs input with embedded "\n" inside one
string, so it doesn't exercise wrap_text's paragraph-joining path; change the
test so input is a Vec<String> of physical lines instead of a single string
containing '\n' (i.e. use lines_vec! with two entries like "Word." and "[^1]"
and the variant with leading spaces " [^1]") when building the `input` passed
to wrap_text in wrap_text_normalizes_split_footnote_refs_in_same_paragraph; keep
the existing assertions unchanged.
🪄 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: 64f50bf5-1e14-4df0-b31a-fed801caf6af
⛔ Files ignored due to path filters (1)
tests/snapshots/inline_footnote_reference_boundary_wrap.snapis excluded by!**/*.snap
📒 Files selected for processing (6)
docs/developers-guide.mddocs/users-guide.mdsrc/wrap/inline.rssrc/wrap/inline/normalize.rstests/wrap_cli.rstests/wrap_unit/footnotes.rs
|
@coderabbitai resume |
✅ Action performedReviews resumed. |
Replace the British "normalised" variant in users guide prose with "normalized" to match documented -ize conventions. Adjust the inline footnote split test to pass physical lines (`Word.` + `[^1]`) so it exercises paragraph joining behaviour instead of encoding a newline in one string.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
Refactor `wrap_text_normalizes_split_footnote_refs_in_same_paragraph` to use `lines_vec!`-based `Vec<String>` test cases directly so the input already represents physical lines. Remove the implicit newline split in test setup so the case validates paragraph joining behavior.
Remove the stray blank line in `wrap_text_normalizes_split_footnote_refs_in_same_paragraph` after the function signature so `cargo fmt --check` is clean.
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== tests/wrap_unit/footnotes.rs (lines 80-120) ==="
fd -e rs -p 'footnotes' --exec sed -n '80,120p' {}Length of output: 10422
#[rstest]
#[case(lines_vec!["Word.", "[^1]"])]
#[case(lines_vec!["Word.", " [^1]"])]
fn wrap_text_normalizes_split_footnote_refs_in_same_paragraph(#[case] input: Vec<String>) {
assert_eq!(wrap_text(&input, 80), lines_vec!["Word.[^1]"]);
}The embedded |
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@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)
|
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
echo "=== architecture.md (full) ==="
fd -i 'architecture.md' --exec cat {}Length of output: 22867
No further work is required. |
Summary
This branch preserves the attachment between sentence punctuation and immediately following inline GFM footnote references during Markdown wrapping and reflow.
Closes #353.
Review walkthrough
Validation
cargo test footnote_ref_spacing: passed.cargo test --test wrap_unit footnote: passed.cargo test --test wrap_cli footnote: passed.make check-fmt: passed.make lint: passed.make test: passed.make markdownlint: passed.coderabbit review --agent --type uncommitted: completed with 0 findings.coderabbit review --agent --type committed --base origin/main: completed with 0 findings after the free CLI rate-limit wait.Notes
The first full-branch CodeRabbit attempt exceeded the free CLI file limit because local
mainis stale. The committed review was rerun againstorigin/main, which matches the pull request diff.