Conversation
If no header markup is detected the converter now treats the first row as the header. Updated docs and tests.
Reviewer's GuideAdds logic to fallback to using the first row as a header when no explicit header markup is found, and updates the documentation and tests to reflect this new behavior. Class diagram for table header detection logicclassDiagram
class TableConverter {
+table_node_to_markdown(table: Handle) Vec<String>
-first_header: bool
-row_handles: Vec<Handle>
-col_count: usize
}
TableConverter : +Detects header row by checking for <th>, <strong>, <b> in first row
TableConverter : +If no header markup and multiple rows, fallback to first row as header
Flow diagram for table header fallback logicflowchart TD
A[Start table conversion] --> B{First row contains header markup?}
B -- Yes --> C[Use first row as header]
B -- No --> D{Table has multiple rows?}
D -- Yes --> E[Fallback: Use first row as header]
D -- No --> F[No header row]
C --> G[Insert separator line in Markdown]
E --> G
F --> H[No separator line]
G --> I[Continue conversion]
H --> I
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Rate limit exceeded@leynos has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 10 minutes and 55 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. 📒 Files selected for processing (3)
Summary by CodeRabbit
WalkthroughExtend the HTML-to-Markdown table converter to always treat the first row as a header if no explicit header markup is found and the table has multiple rows. Update documentation to clarify header detection logic and modify the relevant test to expect a Markdown header separator line in such cases. Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant Converter
participant Markdown
User->>Converter: Provide HTML table
Converter->>Converter: Inspect first row for <th> or strong formatting
alt Header detected
Converter->>Markdown: Output header row and separator
else No header detected, multiple rows
Converter->>Markdown: Treat first row as header, insert separator
end
Converter->>Markdown: Output remaining rows as data
Possibly related PRs
Poem
✨ 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 found some issues that need to be addressed.
- Consider refactoring the header detection and fallback logic so that you determine whether there’s a header (explicit or fallback) before you render any rows, which would make the code flow more straightforward.
- The
first_headervariable is really a boolean flag—renaming it to something likehas_headeror splitting it into explicit vs fallback flags could make the intent clearer and avoid confusion.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider refactoring the header detection and fallback logic so that you determine whether there’s a header (explicit or fallback) before you render any rows, which would make the code flow more straightforward.
- The `first_header` variable is really a boolean flag—renaming it to something like `has_header` or splitting it into explicit vs fallback flags could make the intent clearer and avoid confusion.
## Individual Comments
### Comment 1
<location> `tests/integration.rs:460` </location>
<code_context>
#[test]
fn test_convert_html_table_no_header() {
- let expected = vec!["| A | B |", "| 1 | 2 |"];
+ let expected = vec!["| A | B |", "| --- | --- |", "| 1 | 2 |"];
assert_eq!(convert_html_tables(&html_table_no_header()), expected);
}
</code_context>
<issue_to_address>
Consider adding tests for edge cases where the first row is empty or contains only whitespace.
Please also add tests for cases where the first row is empty, contains only whitespace, or has inconsistent cell counts to ensure the fallback logic handles these scenarios correctly.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro
📒 Files selected for processing (3)
docs/html-table-support.md(1 hunks)src/html.rs(1 hunks)tests/integration.rs(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
**/*.rs
Instructions used from:
Sources:
⚙️ CodeRabbit Configuration File
🪛 LanguageTool
docs/html-table-support.md
[uncategorized] ~23-~23: Use a comma before ‘so’ if it connects two independent clauses (unless they are closely connected and short).
Context: ...first row is still treated as the header so the Markdown output includes a separato...
(COMMA_COMPOUND_SENTENCE_2)
⏰ Context from checks skipped due to timeout of 240000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: build-test
🔇 Additional comments (2)
src/html.rs (1)
148-151: Approve the fallback header logic implementation.The conditional logic correctly implements the fallback behaviour: treating the first row as a header when no explicit header markup exists and the table has multiple rows. The edge case handling for single-row tables is appropriate.
tests/integration.rs (1)
460-460: Approve the test expectation update.The updated expected output correctly reflects the fallback header behaviour for tables without explicit header markup, ensuring the test validates the new implementation.
Summary
Testing
cargo clippy -- -D warningsRUSTFLAGS="-D warnings" cargo testmarkdownlint README.md docs/*.mdnixie README.md docs/*.mdhttps://chatgpt.com/codex/tasks/task_e_6873a8cc9208832293665fc8491f7b2a
Summary by Sourcery
Implement fallback header detection for HTML table conversion when no header tags are present.
Enhancements:
Documentation:
Tests: