Skip to content

Handle colon-separated footnotes#185

Merged
leynos merged 3 commits intomainfrom
codex/add-support-for-new-footnote-type
Aug 10, 2025
Merged

Handle colon-separated footnotes#185
leynos merged 3 commits intomainfrom
codex/add-support-for-new-footnote-type

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Aug 8, 2025

Summary

  • convert bare 7: references into [^7]: links
  • document colon-based footnote support
  • cover colon footnotes in tests

Testing

  • make fmt
  • make lint
  • make test
  • make markdownlint
  • make nixie (fails: RuntimeError: Error running command bun x --bun @mermaid-js/mermaid-cli mmdc -p /tmp/tmpw32pa7sq.json -i /tmp/tmp7i9oe1ec/architecture_1.mmd -o /tmp/tmp7i9oe1ec/architecture_1.svg for file 'docs/architecture.md' (diagram 1): error: too many arguments. Expected 0 arguments but got 1.)

https://chatgpt.com/codex/tasks/task_e_68960ac13cc88322bb27b43391f38016

Summary by Sourcery

Add support for colon-separated footnote references and definitions in markdown processing, update related regex patterns, tests, and documentation.

New Features:

  • Detect and convert bare numeric references followed by a colon into markdown footnote links
  • Convert footnote definitions using a colon separator into standard markdown footnote definitions

Enhancements:

  • Extend inline and footnote definition regex patterns to match colon-based syntax

Documentation:

  • Document colon-separated footnote support and update examples in architecture.md

Tests:

  • Add tests for converting number-colon inline footnotes
  • Add tests for converting colon-separated footnote definitions

@sourcery-ai
Copy link
Copy Markdown
Contributor

sourcery-ai Bot commented Aug 8, 2025

Reviewer's Guide

This PR enhances the footnote conversion logic to recognize and process colon-separated references by introducing a new regex and updating conversion flow, extends definition parsing, adds corresponding tests, and updates documentation accordingly.

Class diagram for updated footnote conversion logic

classDiagram
    class FootnoteConverter {
        +convert_inline(text: &str) String
        -INLINE_FN_RE: Regex
        -COLON_FN_RE: Regex // NEW: Handles colon-separated footnotes
        -FOOTNOTE_LINE_RE: Regex // MODIFIED: Now matches both '.' and ':'
        -build_footnote(...)
        -capture_parts(...)
    }
Loading

File-Level Changes

Change Details Files
Support colon-separated inline footnote references
  • Define COLON_FN_RE to match numbers followed by colon
  • Chain colon-based replacement after existing inline conversion
  • Format replacement to produce [^n]: syntax
src/footnotes.rs
Allow colon in footnote definition lines
  • Modify FOOTNOTE_LINE_RE to accept '.' or ':' as separator
src/footnotes.rs
Add tests covering colon-based footnotes
  • Add test for inline number followed by colon conversion
  • Add test for colon-based definition conversion
tests/footnotes.rs
Document colon-based footnote support
  • Update docs to mention colon-based inline references
  • Add examples demonstrating colon-style footnotes
docs/architecture.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

sourcery-ai[bot]

This comment was marked as resolved.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 8, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Summary by CodeRabbit

  • New Features
    • Enhanced footnote conversion to recognise and process numeric references followed by colons, in addition to previous punctuation styles.
  • Documentation
    • Updated documentation to clarify handling of numeric footnote references before colons, with new illustrative examples.
  • Tests
    • Added new test cases to ensure correct conversion of footnotes with colon suffixes in various scenarios.

Walkthrough

Expand footnote handling to support numeric references followed by a colon in both inline and definition contexts. Update the regular expressions and conversion logic to recognise this new pattern. Add corresponding documentation and tests to reflect and verify the extended functionality. No public API changes are introduced.

Changes

Cohort / File(s) Change Summary
Documentation Update
docs/architecture.md
Clarify and extend documentation for footnote conversion to include numeric references before colons, with new examples.
Footnote Conversion Logic
src/footnotes.rs
Add new regex for colon-style footnote references, update conversion logic to handle colon as a suffix, and adjust existing patterns.
Footnote Conversion Tests
tests/footnotes.rs
Add tests for converting numbers followed by a colon, and for colon-style footnote definition lines.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Converter
    participant RegexEngine

    User->>Converter: Submit markdown with numeric footnote references (incl. colon pattern)
    Converter->>RegexEngine: Match inline footnote patterns
    RegexEngine-->>Converter: Return matches (dot, colon, etc.)
    Converter->>RegexEngine: Match colon-style footnote references
    RegexEngine-->>Converter: Return colon matches
    Converter->>User: Return markdown with converted footnote references
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

Footnotes now with colons, how neat,
Regex patterns rise to greet!
Docs and tests in tidy rows,
Each new case the parser knows.
Markdown’s quirks now less forlorn—
Let footnote magic be reborn!
📝✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38840c3 and 490d465.

📒 Files selected for processing (1)
  • src/footnotes.rs (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • src/footnotes.rs
🔇 Additional comments (3)
src/footnotes.rs (3)

22-22: Accept colon in footnote definition lines.

Keep this; it correctly recognises both “1.” and “1:”.

Add tests that cover “1: text” lines in the trailing block to assert that they are normalised consistently with “1. text”.


47-50: Retain the first pass for punctuation-before-number inline refs.

LGTM. Keep this pass as-is before the colon pathway.


16-19: Ignore outdated test addition for colon-path inline refs
Tests in tests/footnotes.rs already cover single/multiple colons, optional spaces pre-colon and trailing punctuation (lines 103 and 114). No further test additions required.

Likely an incorrect or invalid review comment.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/add-support-for-new-footnote-type

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
tests/footnotes.rs (1)

87-100: Add edge-case coverage and parameterise with rstest.

Add cases for:

  • Multiple trailing colons (e.g., “12::”).
  • Colon followed by punctuation (e.g., “8:;”).
  • Extra whitespace before/after the colon (e.g., “ 9 : ”).
  • Styled markers before numbers (e.g., “_7:” or “*7:”).

Prefer rstest to reduce duplication.

Example:

use rstest::rstest;

#[rstest(
    input, expected,
    case(lines_vec!("This is a reference 12:: to something important."),
         lines_vec!("This is a reference[^12]:: to something important.")),
    case(lines_vec!("Another case is 8:; for completeness."),
         lines_vec!("Another case is[^8]:; for completeness.")),
    case(lines_vec!("This is a tricky one  9 : and should be handled."),
         lines_vec!("This is a tricky one[^9]: and should be handled.")),
    case(lines_vec!("Styled footnote _7: appears here."),
         lines_vec!("Styled footnote _[^7]: appears here.")),
)]
fn converts_colon_variants(input: Vec<String>, expected: Vec<String>) {
    assert_eq!(convert_footnotes(&input), expected);
}

Also applies to: 102-107

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 37acd4f and 8fb7706.

📒 Files selected for processing (3)
  • docs/architecture.md (2 hunks)
  • src/footnotes.rs (2 hunks)
  • tests/footnotes.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
docs/**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

docs/**/*.md: Use the markdown files within the docs/ directory as a knowledge base and source of truth for project requirements, dependency choices, and architectural decisions.
When new decisions are made, requirements change, libraries are added/removed, or architectural patterns evolve, proactively update the relevant file(s) in the docs/ directory to reflect the latest state. Ensure the documentation remains accurate and current.

Files:

  • docs/architecture.md
**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.md: Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged for community consistency.)
Validate Markdown files using make markdownlint.
Run make fmt after any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by running make nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
Use dashes (-) for list bullets.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.

Files:

  • docs/architecture.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • docs/architecture.md
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums: Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary: Use eyre::Report for human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library: Convert to domain enums at API boundaries, and to eyre only in the main main() entrypoint or top-level async task.

Files:

  • tests/footnotes.rs
  • src/footnotes.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • tests/footnotes.rs
  • src/footnotes.rs
🔇 Additional comments (6)
src/footnotes.rs (1)

21-24: Accepting “.” or “:” in footnote definition lines looks good.

The updated FOOTNOTE_LINE_RE correctly matches numbered definitions ending in a dot or a colon.

tests/footnotes.rs (2)

87-100: Approve: Inline “number followed by colon” case is covered.

The test asserts the intended transformation and matches the documented behaviour.


102-107: Approve: Footnote definition with colon is covered.

The test verifies FOOTNOTE_LINE_RE and the block conversion path.

docs/architecture.md (3)

99-105: Document colon-based references succinctly; this reads well.

The section now clearly states “after punctuation or before a colon” and includes a minimal example.


113-115: Align examples with code: include colon in the “After” output.

The examples correctly show “[^7]:” with the colon retained, consistent with the implementation.

Also applies to: 119-128


99-105: Avoid triple backticks inside Mermaid fences

Pinpoint the offending label and rephrase to remove literal backticks:

• docs/architecture.md:55

Apply this diff:

- Streaming --> InCodeFence: Line is a fence delimiter ("```" or "~~~")
+ Streaming --> InCodeFence: Line is a fence delimiter ('backticks' or 'tildes')

Likely an incorrect or invalid review comment.

Comment thread src/footnotes.rs
Comment thread src/footnotes.rs
coderabbitai[bot]

This comment was marked as resolved.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 10, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos

This comment was marked as resolved.

greptile-apps[bot]

This comment was marked as resolved.

@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Aug 10, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Aug 10, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@leynos leynos merged commit 3ac275f into main Aug 10, 2025
2 checks passed
@leynos leynos deleted the codex/add-support-for-new-footnote-type branch August 10, 2025 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant