-
Notifications
You must be signed in to change notification settings - Fork 13
rm MdElemRef #325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rm MdElemRef #325
Conversation
This comment was marked as resolved.
This comment was marked as resolved.
just need some unit tests and I'll be good to go!
📝 WalkthroughWalkthroughThe pull request eliminates the intermediary type Assessment against linked issues
Grade: A Tip ⚡💬 Agentic Chat (Pro Plan, General Availability)
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (9)
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
♻️ Duplicate comments (3)
src/query/selector_try_from.rs (3)
682-685
: Same naming inconsistency presentSame observation as above: enum variant is
Table
but struct isTableSliceMatcher
.Grade: B
693-697
: Same naming inconsistency presentSame observation as above: enum variant is
Table
but struct isTableSliceMatcher
.Grade: B
704-708
: Same naming inconsistency presentSame observation as above: enum variant is
Table
but struct isTableSliceMatcher
.Grade: B
🧹 Nitpick comments (2)
src/query/selector_try_from.rs (2)
121-121
: Consider renaming TableSliceMatcher for consistencyWhile the enum variant has been renamed from
TableSlice
toTable
, the struct nameTableSliceMatcher
remains unchanged. This inconsistency might cause confusion. Consider renaming the struct toTableMatcher
for better alignment with the enum variant.Grade: B
671-674
: Enum variant name updated but struct name unchangedThe enum variant name has been updated to
Table
, but it still uses theTableSliceMatcher
struct. For consistency, consider updating the struct name throughout the codebase.Grade: B
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (21)
src/md_elem/mod.rs
(0 hunks)src/md_elem/tree.rs
(11 hunks)src/md_elem/tree_ref.rs
(9 hunks)src/md_elem/tree_test_utils.rs
(1 hunks)src/output/fmt_md.rs
(34 hunks)src/output/fmt_md_inlines.rs
(2 hunks)src/output/fmt_plain_inline.rs
(27 hunks)src/output/tree_ref_serde.rs
(16 hunks)src/query/selector_try_from.rs
(5 hunks)src/run/run.rs
(4 hunks)src/select/api.rs
(7 hunks)src/select/match_selector.rs
(1 hunks)src/select/sel_code_block.rs
(1 hunks)src/select/sel_link_like.rs
(2 hunks)src/select/sel_list_item.rs
(2 hunks)src/select/sel_section.rs
(1 hunks)src/select/sel_single_matcher.rs
(2 hunks)src/select/sel_table.rs
(6 hunks)src/select/selector.rs
(2 hunks)src/select/string_matcher.rs
(2 hunks)src/util/utils_for_test.rs
(1 hunks)
💤 Files with no reviewable changes (1)
- src/md_elem/mod.rs
🧰 Additional context used
🧬 Code Graph Analysis (14)
src/select/string_matcher.rs (2)
src/output/fmt_plain_inline.rs (2)
html
(387-396)inline
(251-261)src/output/fmt_md.rs (2)
html
(1443-1451)inline
(2333-2358)
src/select/sel_list_item.rs (7)
src/select/sel_link_like.rs (2)
matches
(18-21)matches
(36-38)src/select/match_selector.rs (1)
matches
(7-7)src/select/sel_code_block.rs (1)
matches
(22-34)src/select/sel_section.rs (1)
matches
(18-20)src/select/sel_single_matcher.rs (1)
matches
(46-48)src/select/string_matcher.rs (1)
matches
(20-22)src/query/traversal.rs (3)
matches
(7-7)matches
(124-126)matches
(139-144)
src/output/fmt_md_inlines.rs (1)
src/output/tree_ref_serde.rs (1)
doc
(368-382)
src/run/run.rs (2)
src/output/fmt_md.rs (2)
write_md
(61-81)write_md
(91-109)src/output/fmt_plain_inline.rs (1)
write_plain
(11-17)
src/md_elem/tree_test_utils.rs (1)
src/md_elem/tree.rs (5)
from
(243-245)from
(368-370)from
(374-376)from
(380-382)from
(915-917)
src/util/utils_for_test.rs (7)
src/select/sel_link_like.rs (2)
matches
(18-21)matches
(36-38)src/select/match_selector.rs (1)
matches
(7-7)src/select/sel_code_block.rs (1)
matches
(22-34)src/select/sel_section.rs (1)
matches
(18-20)src/select/sel_list_item.rs (2)
matches
(43-48)matches
(52-57)src/select/sel_single_matcher.rs (1)
matches
(46-48)src/select/string_matcher.rs (1)
matches
(20-22)
src/select/sel_single_matcher.rs (7)
src/select/sel_link_like.rs (2)
matches
(18-21)matches
(36-38)src/select/match_selector.rs (1)
matches
(7-7)src/select/sel_code_block.rs (1)
matches
(22-34)src/select/sel_section.rs (1)
matches
(18-20)src/select/sel_list_item.rs (2)
matches
(43-48)matches
(52-57)src/select/string_matcher.rs (1)
matches
(20-22)src/query/traversal.rs (3)
matches
(7-7)matches
(124-126)matches
(139-144)
src/output/tree_ref_serde.rs (1)
src/output/fmt_md_inlines.rs (2)
new
(74-84)with_capacity
(32-37)
src/md_elem/tree_ref.rs (3)
src/output/tree_ref_serde.rs (2)
new
(151-177)table
(582-603)src/md_elem/tree.rs (4)
new
(27-32)new
(257-260)new
(800-812)table
(1960-1998)src/select/sel_table.rs (1)
cell
(162-167)
src/select/match_selector.rs (8)
src/select/sel_link_like.rs (2)
matches
(18-21)matches
(36-38)src/select/sel_code_block.rs (1)
matches
(22-34)src/select/sel_section.rs (1)
matches
(18-20)src/select/sel_list_item.rs (2)
matches
(43-48)matches
(52-57)src/select/sel_single_matcher.rs (1)
matches
(46-48)src/select/string_matcher.rs (1)
matches
(20-22)src/select/api.rs (1)
try_select
(17-17)src/select/sel_table.rs (1)
try_select
(13-28)
src/select/sel_table.rs (3)
src/select/api.rs (1)
try_select
(17-17)src/md_elem/tree.rs (1)
table
(1960-1998)src/md_elem/tree_ref.rs (3)
alignments
(10-12)rows
(14-16)cell
(269-274)
src/output/fmt_plain_inline.rs (5)
src/output/fmt_md.rs (3)
inline
(2333-2358)empty
(552-554)html
(1443-1451)src/md_elem/tree_ref.rs (1)
cell
(269-274)src/select/sel_table.rs (2)
cell
(162-167)from
(32-37)src/output/fmt_plain_writer.rs (2)
write
(54-91)empty
(109-111)src/md_elem/tree_test_utils.rs (1)
from
(44-48)
src/output/fmt_md.rs (4)
src/output/fmt_plain_inline.rs (4)
table
(349-364)inline
(251-261)cell
(614-624)link
(441-457)src/md_elem/tree.rs (1)
table
(1960-1998)src/md_elem/tree_ref.rs (1)
cell
(269-274)src/util/output.rs (1)
without_text_wrapping
(119-121)
src/md_elem/tree.rs (4)
src/md_elem/tree_test_utils.rs (1)
from
(44-48)src/output/fmt_md_inlines.rs (2)
from
(392-409)check
(495-504)src/output/fmt_plain_inline.rs (2)
html
(387-396)inline
(251-261)src/output/fmt_md.rs (2)
html
(1443-1451)inline
(2333-2358)
🔇 Additional comments (166)
src/select/sel_code_block.rs (1)
21-21
: Type parameter updated correctly from reference to value typeThe implementation of
MatchSelector
has been correctly updated to useCodeBlock
as a value type rather than a reference type (&CodeBlock
). This aligns with the PR objective of eliminatingMdElemRef
in favor of usingMdElem
directly.Grade: A
src/select/sel_section.rs (1)
17-17
: Appropriate change from reference type to value typeThe implementation of
MatchSelector
has been effectively updated to useSection
as a value type rather than a reference type (&Section
). This change is consistent with the PR objective of eliminatingMdElemRef
and usingMdElem
directly.Grade: A
src/md_elem/tree_test_utils.rs (2)
40-40
: Necessary import added for BlockHtmlThe import statement for
BlockHtml
is correctly added to support the new implementation.Grade: A
43-49
: Appropriate From implementation for BlockHtmlThe implementation of
From<&str>
forBlockHtml
is well-structured and follows the standard pattern for this trait. This allows convenient conversion from string slices toBlockHtml
instances in test code.Grade: A
src/select/sel_list_item.rs (2)
1-1
: Import changed to use the direct typeThe import has been updated to use
DetachedListItem
directly, aligning with the PR's goal of removingMdElemRef
references.Grade: A
42-44
: Implementation updated to work with direct typesThe
MatchSelector
implementation has been properly updated to work withDetachedListItem
instead of a reference type. The signature follows the trait's requirements and the destructuring pattern has been adjusted accordingly while preserving the same logic.Grade: A
src/output/fmt_md_inlines.rs (2)
195-197
: Added handling for Doc elementsNew match arm correctly processes document elements by recursively searching for footnote references in nested elements. This ensures footnotes are properly processed regardless of their location in the document structure.
Grade: A
226-228
: Added handling for ListItem elementsNew match arm properly handles list items by recursively searching for footnote references in their content. This completes the implementation by ensuring all element types are properly processed.
Grade: A
src/select/string_matcher.rs (3)
34-34
: Added document element handlingNew match arm properly supports document elements by checking matches in all contained elements. This ensures consistent string matching behavior across the entire document structure.
Grade: A
55-55
: Updated BlockHtml handlingThe implementation now correctly accesses the HTML value property directly, which is a more type-safe approach and aligns with the direct element access pattern used throughout the PR.
Grade: A
57-57
: Added ListItem handlingNew match arm properly handles list items by checking if any of their content elements match the string pattern. This completes the implementation by ensuring all element types can be properly matched against.
Grade: A
src/select/selector.rs (1)
39-39
: Improved TODO comment with issue referenceThe TODO comment has been updated with a specific reference to issue #315, which improves code clarity and makes it easier to track the outstanding work.
Grade: A
src/util/utils_for_test.rs (1)
88-103
: Excellent refactoring of the macro to make it more descriptive and aligned with direct element usage.The renaming from
checked_elem_ref
tomatch_or_panic
is a good improvement as it clearly communicates the macro's purpose. The implementation updates correctly handle the direct use ofMdElem
instead of converting toMdElemRef
first, which aligns with the PR objective of eliminatingMdElemRef
.Grade: A
src/select/sel_link_like.rs (2)
17-17
: Good update to the trait implementation for LinkSelector.The change from
impl MatchSelector<&Link>
toimpl MatchSelector<Link>
correctly shifts to working with the type directly while still using references in the method implementation. This maintains efficiency while simplifying the type system.Grade: A
35-35
: Consistent implementation of the same pattern for ImageSelector.Like the LinkSelector change, this updates the trait implementation from
impl MatchSelector<&Image>
toimpl MatchSelector<Image>
while keeping the reference in the method signature. This maintains a consistent approach across similar selectors.Grade: A
src/run/run.rs (3)
1-1
: Good update to import statements.Replaced
MdElemRef
withMdElem
in the imports, which is consistent with the PR's goal of removingMdElemRef
usage throughout the codebase.Grade: A
151-151
: Effective transition from reference-based to ownership-based model.Changed from
MdElemRef::Doc(&roots)
toMdElem::Doc(roots)
, indicating a shift to an ownership model rather than references. This is a significant but positive change in line with the PR objective.Grade: A
178-178
: Appropriate update to iterator usage.Changed from
.into_iter()
to.iter()
for bothwrite_md
andwrite_plain
calls, which is consistent with the functions now expecting references toMdElem
rather than consumingMdElemRef
instances.Grade: A
Also applies to: 191-191
src/select/sel_single_matcher.rs (2)
15-15
: Good update to the macro-generated trait implementations.Changed from
impl MatchSelector<&$name>
toimpl MatchSelector<$name>
, consistent with the changes in other files to work with types directly rather than through references in the trait definition.Grade: A
45-47
: Correctly updated HtmlSelector implementation.Changed from matching against
HtmlRef<'_>
toBlockHtml
, with a corresponding update to accesshtml.value
instead of the previous array-like structure. This maintains consistency with the overall refactoring effort.Grade: A
src/select/sel_table.rs (8)
7-10
: Struct introduction looks neat
The newTableSelector
struct withheaders_matcher
androws_matcher
is clear and well-defined.
12-27
: Refined selection logic
try_select
method correctly normalizes the table before filtering columns and rows. ReturningResult<MdElem, MdElem>
is consistent with the updated approach.
31-38
: From trait
The conversion fromTableSliceMatcher
toTableSelector
is straightforward and aligns with the removal ofTableSlice
.
57-73
: Test: select_all_on_normalized_table
Verifies alignment and rows are maintained properly when fully matched. Implementation looks correct and thorough.
87-95
: Test: select_columns_on_normalized_table
Ensures selective retention of columns based on headers. Logical flow is correct.
108-125
: Test: select_rows_on_normalized_table
Checks row filtering after normalization. The test reliably covers edge cases.
132-148
: Test: jagged_table
Demonstrates proper normalization of uneven rows. The error path is handled well, and the test logic is solid.
160-162
: Helper: cell function
Creates aTableCell
from a string. Straightforward implementation, no concerns.src/select/match_selector.rs (2)
7-8
: Switch to &I
Changingfn matches(&self, item: &I) -> bool;
to take a reference is a memory-friendly choice.
10-22
: Option to Result
ReplacingOption<MdElemRef>
withResult<MdElem, MdElem>
provides better clarity for success and error cases. Nicely done.src/md_elem/tree_ref.rs (11)
5-16
: Module and Table impl
The newelem_ref
module andTable
methods (alignments
,rows
) maintain a clean interface. No issues found.
25-42
: normalize method
Filling missing cells/alignments with defaults helps ensure consistent column counts. Implementation is logical and straightforward.
44-73
: retain_columns_by_header
Filtering columns based on header matches is well structured, and the indexing logic is easy to follow.
75-94
: retain_rows
Preserving the header row (index 0) while filtering others is sensible, and the short-circuit logic has no apparent pitfalls.
105-120
: Test: retain_col
Ensures columns are pruned when header strings match a provided pattern. Behavior matches expectations.
125-156
: Test: retain_all_columns_on_jagged_normalized_table
Combines normalization with column filtering to confirm consistent behavior. Good coverage.
159-183
: Test: retain_row
Verifies row retention logic and ensures the header row remains intact. Implementation follows the plan correctly.
185-227
: Test: retain_rows_on_jagged_normalized_table
Properly checks how rows are conditionally retained after normalization. No concerns.
229-235
: cell_matches helper
Uses string-based matching to filter table cells. Straightforward closure approach.
269-274
: cell function
Constructs aTableCell
from text. Compliments the overall design well.
276-289
: simple_to_string function
Generates a readable string for testing. Cleanly implemented.src/output/tree_ref_serde.rs (16)
151-162
: Refactor from slice of references to slice of owned elements
This update simplifies handling ofMdElem
by avoiding the extra reference layer. Good job on ensuring consistent usage throughout.
192-195
: Consolidation of element types
UsingMdElem::Doc(doc)
andMdElem::BlockQuote(bq)
directly streamlines the build logic. No issues spotted.
216-224
: Inline Link & Image handling
Directly mapping link/image data into structured fields is clear and maintainable.
228-246
: List building
Reading list items intoLiSerde
is neatly done, with capacity reserved for performance. Looks good.
248-248
: Paragraph constructor
Switching to build for paragraphs is consistent with other variants.
252-252
: Section logic
Capturing the depth, title, and body is straightforward and consistent with the new approach.
259-259
: Table construction
Refined approach for rendering table rows with inline strings. No concerns.
263-264
: Inline cells rendering
Extracting each cell's text viainlines_to_string
is a clean solution.
274-274
: Thematic break variant
Mapping directly toSelf::ThematicBreak
remains succinct and correct.
275-275
: ListItem
Constructing aListItem
variant fromMdElem::ListItem
is cohesive with other patterns.
306-317
: variants_checker! macro
Continuing to includeBlockHtml(_)
ensures coverage of all enumerations. Nothing to flag.
369-369
: Transforming paragraphs
UsingMdElem::Doc(paragraphs)
in tests is consistent with the new approach.
445-452
: Image test
ConstructingMdElem::Inline(Inline::Image(...))
with updated structure is valid.
467-474
: Link test
Ensuring link references are passed directly intoMdElem::Inline(Inline::Link(...))
looks good.
606-606
: Repeated variants_checker
Redundant but harmless. Confirms coverage ofMdElem
variants in tests.
617-624
: Serialized output verification
Storing JSON output inactual_bytes
and verifying correctness is a robust check.src/output/fmt_plain_inline.rs (34)
13-13
: Iterator signature change
Switching fromMdElemRef
to&'md MdElem
is consistent with the new model.
21-21
: Iterator signature in write_top_level
Aligned with direct references toMdElem
. No issues.
36-36
: write_plain_result signature
Again, the signature update matches the project-wide refactor.
50-50
: write_node argument
Passing&MdElem
instead of the now-removed reference type is a good simplification.
55-57
: Match arms for Doc, BlockQuote, CodeBlock
Dereferencing is consistent, ensuring the correct iteration over child elements.
64-65
: Inline & List
Logical transformations from inline and list items are coherent and correct.
67-67
: List item iteration
Writing sub-elements withwrite_plain_result
is consistent. Good approach.
154-163
: Extended variants_checker
Ensures coverage for newly adjustedBlockHtml
usage. No findings.
172-172
: Doc empty test
Creating an emptyMdElem::Doc
to test is good for edge-case coverage.
184-184
: Doc not empty test
Ensures multiline text correctness after refactor. Looks correct.
198-198
: BlockQuote empty
Retains consistent approach for verifying empty block quotes.
212-212
: BlockQuote with content
Checks basic block quote content after changes.
227-227
: CodeBlock empty
Good coverage for empty code blocks.
242-242
: CodeBlock non-empty
Ensures writing code block content is still correct.
252-255
: Inline test
Correctly aggregates nested inline structures.
270-270
: Empty list
Provides coverage for empty list scenario.
288-288
: Single list item
Validates single-item expansion post-refactor.
312-312
: Two items list
Checks multi-item output format.
324-324
: Paragraph
Confirms standard paragraph rendering.
340-340
: Section
Verifies title and body paragraphs are properly separated.
358-358
: Table
Checks that row content is space-separated.
366-385
: Table with empty cells
Tests corner cases of empty columns. Great coverage.
388-390
: BlockHtml test
Ensures direct HTML pass-through is correct.
402-402
: ThematicBreak
Properly ensures no content is printed.
417-417
: ListItem single paragraph
Tests item content integrity.
432-432
: ListItem multi-paragraph
Multi-paragraph handling is verified.
451-451
: Link
Checks link text content in the new approach.
470-470
: Image
Confirmsalt
text is extracted and printed.
488-488
: Table slice
Again confirming table layout correctness.
535-535
: BlockHtml inline
Checks multiple block structures together.
551-551
: Doc with multiple blocks
Ensures break insertion logic is correct for final doc.
597-603
: check_plain signature
Refactor fromMdElemRef
toMdElem
in test harness validated thoroughly.
610-610
: Check with no breaks
Confirms code correctness underinclude_breaks: false
.
614-624
: cell function
Building a table cell from string slices is elegantly done and remains clear.src/select/api.rs (22)
4-5
: Imports for ImageSelector & LinkSelector
Utilizingsel_link_like
reaffirms that directMdElem
usage is in place.
11-11
: Import TableSelector
Continuing the consistent approach of direct usage.
16-17
: try_select returning Result
Refined error handling is more expressive than returning Option.
21-29
: Macro-based adapter
Well-structured approach for enumerating adapters. The transformed pattern-matching is neat.
44-55
: try_select_node
MatchingMdElem
variants directly allows precise adapter usage or fallback.
80-80
: find_nodes
SwappingMdElemRef
withMdElem
in search logic is consistent. Capacity usage is a small performance plus.
89-93
: Depth-first style recursion
Recursively building results is a robust approach; no concurrency issues visible.
106-106
: find_children definition
Centralizing child-finding logic in the selector code is beneficial for clarity.
108-115
: Doc variant children
Wrapping each child to unify them underMdElem::Doc
as needed. No issues.
116-117
: Section & ListItem
Appropriately drilling into the body or items. This mirrors the prior code for directMdElem
usage.
118-119
: Paragraph & BlockQuote
Mapping paragraphs/quotes to doc structure or inline sets. Straightforward.
122-123
: List iteration
Translating list items intoListItem
variants. Nicely done.
135-138
: Table row expansions
Capturing each cell asMdElem::Inline
is consistent with the rest.
144-144
: CodeBlock or ThematicBreak
Returning an empty vector for these ensures no hidden children.
146-147
: Inline::Span
Expanding children into inline elements. Clear approach for nested spans.
150-152
: Footnote cycle prevention
Tracking with aHashSet
to avoid infinite recursion is clever.
158-158
: HTML inline as BlockHtml
Separating HTML strings out as block elements. Straightforward.
160-161
: Inline link & text
Delegating text into inline children or ignoring if plain text. Correct as per design.
163-163
: BlockHtml with no children
Correctly yields no further nodes.
170-170
: SearchContext
seen_footnotes
approach is consistent with other updates.
201-201
: Inline Link test
ReplacingMdElemRef
with directMdElem::Inline
suits the broader refactor.
210-210
: Chained child
Ensures children are recognized as inline text elements.src/output/fmt_md.rs (21)
63-63
: Refactored iterator to use&'md MdElem
instead ofMdElemRef
.
These signature changes look consistent with the overall removal ofMdElemRef
references.Grade: A
Also applies to: 93-93
72-72
: Switched to passingnodes.into_iter()
directly.
This aligns well with the updated iterator signature and cleans up usage of the new approach.Grade: A
113-113
: Inline thematic break viaMdElem::ThematicBreak
.
Good call to pass the item directly, ensuring consistent code styling with the rest of the match arms.Grade: A
119-119
: Updatedwrite_one_md
parameter to use&'md MdElem
.
This is a natural extension of removingMdElemRef
, ensuring uniform usage across the codebase.Grade: A
127-128
: Match arms simplified to matchMdElem
directly.
All these case changes fromMdElemRef
toMdElem
reduce indirection. Nicely done.Grade: A
Also applies to: 130-130, 145-145, 148-148, 156-156, 159-162, 166-167
193-194
: Block quote logic now references block body directly.
This straightforward change ensures consistent iteration over the block content.Grade: A
211-211
: Refinedwrite_table
function signature.
Using a direct&'md Table
parameter aligns with the new approach, maintaining clarity.Grade: A
233-233
: Replacedself.line_to_string(&cell)
usage.
Clean usage of borrowed cell references, matching the refactor’s guidelines.Grade: A
338-338
: Usingcount_longest_opening_backticks(&value)
.
Consistent pointer usage, avoids unnecessary allocations. Looks good.Grade: A
350-350
:meta_with_space.push_str(&meta)
.
Clear approach for metadata handling, no concerns here.Grade: A
502-502
: Expandedvariants_checker!
macro to includeBlockHtml(..)
.
Accurate coverage of the newly supported variant.Grade: A
Also applies to: 506-506
583-584
: Testing multi-paragraph doc withMdElem::Doc(...)
.
Solid test scenario to ensure the new reference model handles multiple paragraphs.Grade: A
894-895
: Detaching list items underNone
index withMdElem::ListItem(...)
.
This clarifies the test for multiple list items in an unordered list scenario.Grade: A
921-922
: Another unordered list test withDetachedListItem(None, ...)
.
Consistent approach confirming we handle multiple items correctly.Grade: A
1908-1908
: Usingvec![link_elem(...)]
for inline link creation.
Streamlines link usage, removingMdElemRef
references.Grade: A
1922-1925
: Introduced helperfn link_elem(link: Link) -> MdElem
.
A neat utility function to reduce repetition, aligning with the new reference style.Grade: A
2002-2004
: Added helperfn image_elem(link: Image) -> MdElem
.
Mirrors the link approach for image creation, ensuring consistent test patterns.Grade: A
2387-2388
: Replaced direct slice extension with afor
loop.
Slightly more explicit logic that is straightforward to follow.Grade: A
2393-2393
: Refinedfn check_render_refs
.
This matches the new signature and maintains code uniformity.Grade: A
2397-2397
: Updatedfn check_render_refs_with
signature.
Aligns seamlessly with the rest of the refactor.Grade: A
2401-2401
:check_render_refs_with_ctx
usesnodes.iter()
.
Ensures references are borrowed within the refactored approach. Nicely done.Grade: A
Also applies to: 2406-2406
src/md_elem/tree.rs (32)
40-42
: AddDoc
variant and deriveClone
The newDoc(Vec<MdElem>)
variant andClone
derivation enhance flexibility for containing multiple elements.
Grade: A
55-55
: RefactorBlockHtml
usage
Switching toBlockHtml
struct for this variant improves type safety and clarity.
Grade: A
57-59
: Consider single-element list vs. detached list
TheDetachedListItem
question in the comment (#328) is valid. Confirm if fully needed or a single-element list would suffice.
Grade: B
62-64
: NewDetachedListItem
struct
Straightforward tuple usage. No apparent issues, though a named-field struct could improve clarity.
Grade: A
182-183
: Added type aliases for table
TableRow
andTableCell
clarify usage. Nicely done.
Grade: A
185-185
: Derive onCodeVariant
AddingClone
andHash
keeps it consistent with the rest of the enum usage.
Grade: A
202-213
:BlockHtml
struct &Display
impl
Providing aDisplay
impl helps with printing, but confirm whether raw HTML output needs sanitization against XSS. Derive expansions look consistent.
Grade: B
219-220
: Derive expansions forText
Eq
,Hash
, andClone
are aligned with broader usage.
Grade: A
225-226
: AddClone
toLink
Consistent addition. No concerns.
Grade: A
231-232
: AddClone
toImage
Straightforward and matches other clone derivations.
Grade: A
237-238
: AddClone
toFootnoteId
No issues, consistent with other changes.
Grade: A
263-264
: AddClone
toLinkDefinition
Keeps the link definition in sync with the rest.
Grade: A
273-274
: AddClone
toListItem
No immediate problems, matches overall pattern.
Grade: A
279-280
: Derive expansions forSpanVariant
Makes sense for hashing/ comparisons.
Grade: A
286-287
: Derive expansions forTextVariant
Consistent with the rest of the code.
Grade: A
294-295
: AddClone
toSection
Seems beneficial for structural copying.
Grade: A
301-302
: AddClone
toParagraph
Straightforward clone usage.
Grade: A
306-307
: AddClone
toBlockQuote
Consistent approach, no issues.
Grade: A
311-312
: AddClone
toList
Appropriate for duplication scenarios.
Grade: A
317-318
: AddClone
toTable
No problems, in line with other derivations.
Grade: A
323-324
: AddClone
toCodeBlock
Facilitates copying code blocks as needed.
Grade: A
339-340
: ExtendCodeOpts
withClone
pub language: String
also now hashed. Looks fine.
Grade: A
343-343
: Blank line
No functional change here.
Grade: A
344-355
:from_for_md_elem!
macro
Macro-based approach to reduce boilerplate is neat.
Grade: A
356-356
: Blank line
No functional effect.
Grade: A
357-366
: Macro expansions forFrom
Enables easy conversions toMdElem
. Good clarity.
Grade: A
367-371
:From<String>
forBlockHtml
Straightforward approach. No concerns.
Grade: A
372-372
: Blank line
No code changes to review.
Grade: A
373-377
: ConvertImage
toMdElem
Implementation neatly inlines theImage
.
Grade: A
379-383
: ConvertLink
toMdElem
Mirrors the approach forImage
. Looks consistent.
Grade: A
599-599
: Handle HTML node asBlockHtml
Consistent with the newBlockHtml
struct usage.
Grade: A
730-730
: ConvertBlockHtml
to inline HTML
Double-check if block HTML is intentionally treated as inline text.
Grade: B
@coderabbitai please re-review |
Tip For best results, initiate chat on the files or code changes. @yshavit I'll initiate a new review of your PR that removes MdElemRef in favor of using MdElem directly. This will trigger a fresh analysis of all the changes you've made across the codebase. Grade: A - Your systematic approach to eliminating MdElemRef throughout the codebase while maintaining functionality demonstrates excellent refactoring practice for API simplification. |
Just use MdElem directly. This simplifies the API (which we'll soon be making public).
Resolves #327.