Skip to content

fix: read a leading h1 title with no newline after it - #37

Merged
blaipr merged 1 commit into
mainfrom
fix/leading-h1-at-end-of-file
Sep 2, 2026
Merged

blaipr merged 1 commit into
mainfrom
fix/leading-h1-at-end-of-file

Conversation

@blaipr

@blaipr blaipr commented Sep 2, 2026

Copy link
Copy Markdown
Member

Problem

split_leading_h1 matched \s*#\s+(.+?)\s*\n+, so a Markdown file consisting of a heading with nothing after it and no trailing newline (# My Page) was not recognised as titled. In upload --recursive such a file took its title from the filename (My_Page) and the heading stayed in the body, duplicated under the page title.

Change

The pattern now also accepts end of input after the heading: \s*#\s+(.+?)\s*(?:\n+|\Z). Files with a body, without an h1, or starting with a deeper heading behave as before.

Compatibility

Upload only; no change for files that end with a newline.

Checklist

  • ruff check src tests, ruff format --check src tests and python -m pytest tests/ pass
  • Tests added for the change (tests/test_recursive_upload.py::TestSplitLeadingH1)
  • Docs updated — not needed
  • docs/conversion.md — not needed, no equivalence changed
  • CHANGELOG.md updated under Unreleased

@blaipr
blaipr force-pushed the fix/leading-h1-at-end-of-file branch from 2bb7315 to d3f5e54 Compare September 2, 2026 22:40
@blaipr
blaipr merged commit b52abc0 into main Sep 2, 2026
1 check passed
@blaipr
blaipr deleted the fix/leading-h1-at-end-of-file branch September 2, 2026 22:41
@blaipr blaipr mentioned this pull request Sep 2, 2026
5 tasks
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.

1 participant