Skip to content

frontmatter: find a block list past blank and comment lines - #125

Closed
bfs2021 wants to merge 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/84-frontmatter-comments
Closed

bfs2021 wants to merge 1 commit into
TMHSDigital:mainfrom
bfs2021:fix/84-frontmatter-comments

Conversation

@bfs2021

@bfs2021 bfs2021 commented Oct 22, 2026

Copy link
Copy Markdown

Problem

A comment (or blank line) between a key and its block list makes the parser store the key as null and report the first item as list item without a key above it. The error points at the item, not the comment, so contributors are sent to the wrong line.

tags:
  # content words only
  - low-poly

Fix

When a key has no inline value, skip blank and # lines before checking whether the next content line starts a block list. The comment itself is still ignored by the main loop, so lists interrupted by comments keep working.

Testing

Added assertions for the example above: tags becomes ["low-poly"] and no errors are reported. They failed before the change and pass after it.

npm test → checks 134 assertions across 22 checks, lib 406 assertions.

Fixes #84

A comment between a key and its block list made the look-ahead see the
comment, so the key stayed null and the first item errored as a list item
without a key. Skip blank and comment lines when looking for the list.

Fixes TMHSDigital#84

Signed-off-by: bfs2021 <101915083+bfs2021@users.noreply.github.com>
@TMHSDigital

Copy link
Copy Markdown
Owner

Thank you for this, and for the tests. #124 merged this morning with the same fix for #84 (opened before this PR could be reviewed), so this branch now conflicts with main and the issue is closed. I compared the two line by line and main covers everything here, so I am closing this as superseded rather than asking for a rebase. Contributions are welcome on any of the remaining open issues.

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.

frontmatter: a comment line between a key and its block list produces a misleading error

2 participants