Skip to content

🐛 fix(markdown): filter empty values in Fragment render, join with newline#1431

Merged
harehare merged 2 commits intomainfrom
fix/fragment-render-empty
Mar 12, 2026
Merged

🐛 fix(markdown): filter empty values in Fragment render, join with newline#1431
harehare merged 2 commits intomainfrom
fix/fragment-render-empty

Conversation

@harehare
Copy link
Copy Markdown
Owner

Ensure Fragment node rendering skips empty values and joins non-empty with newline. Add tests for fragment rendering edge cases.

Ensure Fragment node rendering skips empty values and joins non-empty with newline. Add tests for fragment rendering edge cases.
Copilot AI review requested due to automatic review settings March 12, 2026 12:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts Markdown Fragment node rendering in mq-markdown to ignore empty rendered children and to separate non-empty children with newlines, improving output formatting for fragment-based selections and transformations.

Changes:

  • Update Node::Fragment rendering to filter out empty rendered strings and join remaining parts with "\n".
  • Add unit tests covering fragment rendering edge cases (empty, single, multiple, filtering empties).

.map(|value| value.render_with_theme(options, theme))
.collect::<String>(),
.filter(|s| !s.is_empty())
.collect::<Vec<_>>()
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

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

Fragment rendering allocates an intermediate Vec<String> just to call join("\n"). Since itertools::Itertools is already in scope and used elsewhere in this file, this can be simplified to join directly on the iterator (avoids an extra allocation and keeps the style consistent).

Suggested change
.collect::<Vec<_>>()

Copilot uses AI. Check for mistakes.
@harehare harehare merged commit 55cecd4 into main Mar 12, 2026
4 checks passed
@harehare harehare deleted the fix/fragment-render-empty branch March 12, 2026 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants