Skip to content

fix: only extract properties from leading front-matter block#15

Merged
dpecos merged 1 commit into
masterfrom
fix/issue-4-property-extraction
Apr 16, 2026
Merged

fix: only extract properties from leading front-matter block#15
dpecos merged 1 commit into
masterfrom
fix/issue-4-property-extraction

Conversation

@dpecos
Copy link
Copy Markdown
Contributor

@dpecos dpecos commented Apr 16, 2026

Summary

  • Fixes extractProperties in parser.ts to stop consuming key: value lines once a blank line or non-property line is encountered
  • HTML comment properties (<!-- key: value -->) are still extracted anywhere in the source since they are invisible markers by design
  • Updates the one existing test whose expectation was an artifact of the old regex leaving a leading newline
  • Adds four new tests covering the bug scenario and boundary cases

Root cause

The old implementation used a single greedy regex with no anchor:

/^\n*([-\w]+):([^$\n]*)|\n*(?:<!--\s*)([-\w]+):([^$\n]*?)(?:\s*-->)/i

This matched any word: value line anywhere in the slide source, silently consuming content like Example: this line disappears as a property.

Fix

Property extraction now works like YAML front-matter:

  1. Skip any leading blank lines
  2. Consume consecutive key: value lines
  3. Stop immediately at the first blank line or non-property line

Lines appearing after content are never treated as properties.

Closes #4

Previously extractProperties used a greedy regex that consumed any
'word: value' line anywhere in the slide source, causing content lines
like 'Example: this line disappears' to be silently eaten as properties.

Now property extraction stops at the first blank line or non-property
line, matching YAML front-matter conventions. HTML comment properties
(<!-- key: value -->) are still extracted anywhere as they are invisible
markers by design.

Closes #4
@dpecos dpecos merged commit 38e6462 into master Apr 16, 2026
4 checks passed
@dpecos dpecos deleted the fix/issue-4-property-extraction branch April 16, 2026 11:28
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.

Bug: first line of a slide disappears when it is a single word followed by a colon

1 participant