Skip to content

Add missing regression coverage for blank-title H1 skip (issue #23) - #58

Merged
tupe12334 merged 1 commit into
mainfrom
fix/issue-23-skip-empty-h1-heading
Jul 14, 2026
Merged

tupe12334 merged 1 commit into
mainfrom
fix/issue-23-skip-empty-h1-heading

Conversation

@tupe12334

Copy link
Copy Markdown
Member

Bug (issue #23)

mdstore was writing a bare # (H1 with nothing after it) into generated markdown when an item's title is empty/blank — this affects comment items in centy-daemon, which have no title concept.

Status

The actual fix already exists on main (commit ab2db95, "fix: skip empty H1 heading when title is blank"), which was merged closing the duplicate issue #15. Both generate_frontmatter and generate_frontmatter_raw in src/frontmatter.rs already trim the title and skip emitting the # {title} heading line (and the blank line that would follow it) when the trimmed title is empty, for both the with-body and without-body cases.

However, only generate_frontmatter had regression tests for this branch — generate_frontmatter_raw (the untyped serde_yaml::Value variant, which is the one relevant to consumers like centy-daemon that don't have a strongly-typed title field) had no test coverage at all, for this or anything else.

Change

Adds two tests mirroring the existing generate_frontmatter blank-title tests, for generate_frontmatter_raw:

  • test_generate_frontmatter_raw_empty_title_no_body
  • test_generate_frontmatter_raw_whitespace_only_title_with_body

No production code changes — the behavior was already correct, this just closes the test gap so the raw-value path stays protected against regressions.

Verified

  • cargo build — clean
  • cargo test — 115 passed (was 113), 0 failed
  • cargo clippy --all-targets --all-features -- -D warnings — no warnings
  • cargo fmt --check — clean

Closes #23

Issue #23 reports mdstore writing a bare `# ` heading when an item's
title is empty (affects comment items in centy-daemon, which have no
title concept). The fix already landed in ab2db95 (closing duplicate
issue #15) for both generate_frontmatter and generate_frontmatter_raw,
but only generate_frontmatter had regression tests.

Add the missing coverage for generate_frontmatter_raw (empty title/no
body, whitespace-only title/with body), matching the existing test
style, so the raw-value code path used for untyped metadata stays
protected.

Closes #23
@tupe12334
tupe12334 merged commit 002b18a into main Jul 14, 2026
6 checks passed
@tupe12334
tupe12334 deleted the fix/issue-23-skip-empty-h1-heading branch July 14, 2026 13:09
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.

Skip empty H1 heading when title is blank

1 participant