Refactor footnotes and document footnote flag#114
Conversation
Reviewer's GuideThis PR refactors footnote handling by extracting inline helper functions, clarifies naming in block conversion, expands unit tests and integration tests for footnotes, and updates documentation and README to describe the new footnotes option flag. Class diagram for refactored footnote helpers in footnotes.rsclassDiagram
class footnotes {
}
class capture_parts {
+capture_parts(caps: Captures) (fn)
}
class build_footnote {
+build_footnote(pre: str, punc: str, style: str, num: str, boundary: str) String (fn)
}
class convert_inline {
+convert_inline(text: str) String (fn)
}
footnotes <.. capture_parts : uses
footnotes <.. build_footnote : uses
convert_inline ..> capture_parts : calls
convert_inline ..> build_footnote : calls
Class diagram for updated convert_block function variable namingclassDiagram
class convert_block {
+convert_block(lines: &mut [String]) (fn)
-footnote_start
-trimmed_end
}
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary by CodeRabbit
WalkthroughUpdate documentation and usage examples to clarify how to enable footnote conversion in the library. Refactor internal footnote conversion logic for improved modularity by extracting helper functions. Add new unit and integration tests to increase coverage and verify macro availability. No changes to public APIs or core behaviour. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Library
participant Footnotes
User->>Library: Call process_stream_opts(input, Options { footnotes: true, ... })
Library->>Footnotes: convert_footnotes(input)
Footnotes->>Footnotes: convert_inline()
Footnotes->>Footnotes: convert_block()
Footnotes-->>Library: converted_output
Library-->>User: output with GitHub-style footnotes
Estimated code review effort2 (~15 minutes) Possibly related PRs
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🧰 Additional context used📓 Path-based instructions (2)**/*.md⚙️ CodeRabbit Configuration File
Files:
**/*.rs⚙️ CodeRabbit Configuration File
Files:
🪛 LanguageTooldocs/footnote-conversion.md[typographical] ~6-~6: Two consecutive dots (DOUBLE_PUNCTUATION) 🔇 Additional comments (7)
✨ Finishing Touches
🧪 Generate unit tests
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Hey @leynos - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/footnotes.rs:82` </location>
<code_context>
+ let (footnote_start, trimmed_end) = trimmed_range(lines, |l| FOOTNOTE_LINE_RE.is_match(l));
- if start >= end || lines[start].trim_start().starts_with("[^") {
+ if footnote_start >= trimmed_end || lines[footnote_start].trim_start().starts_with("[^") {
return;
}
</code_context>
<issue_to_address>
The early return condition may skip valid footnote blocks if the first line is already formatted.
Currently, if the first line is already in footnote format, the function exits and does not process the rest of the block. Please verify if this is intentional or if lines after the first should also be checked for conversion.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| let (footnote_start, trimmed_end) = trimmed_range(lines, |l| FOOTNOTE_LINE_RE.is_match(l)); | ||
|
|
||
| if start >= end || lines[start].trim_start().starts_with("[^") { | ||
| if footnote_start >= trimmed_end || lines[footnote_start].trim_start().starts_with("[^") { |
There was a problem hiding this comment.
question (bug_risk): The early return condition may skip valid footnote blocks if the first line is already formatted.
Currently, if the first line is already in footnote format, the function exits and does not process the rest of the block. Please verify if this is intentional or if lines after the first should also be checked for conversion.
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Summary
convert_footnotesunit testsTesting
make lintmake testhttps://chatgpt.com/codex/tasks/task_e_687d7e6c5ee48322beb353597af98426
Summary by Sourcery
Refactor inline and block footnote conversion logic, extend tests for various footnote scenarios, and document the footnotes option in README and docs.
Enhancements:
Documentation:
Tests: