Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion site/lib/frontmatter.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ export function parseFrontmatter(text) {
return;
}
const value = parseScalar(line.slice(idx + 1));
const next = lines[i + 1];
let nextIndex = i + 1;
while (nextIndex < lines.length && (!lines[nextIndex].trim() || lines[nextIndex].trim().startsWith("#"))) {
nextIndex += 1;
}
const next = lines[nextIndex];
if (value === null && next !== undefined && /^\s+-\s/.test(next)) {
meta[key] = [];
listKey = key;
Expand Down
3 changes: 3 additions & 0 deletions site/lib/lib.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,9 @@ const f1 = fm([
eq("frontmatter undoes quote escapes", f1.meta.attribution_string, 'Music "{title}" by {artist}');
eq("frontmatter keeps a quoted comma inside one list item", JSON.stringify(f1.meta.tags), JSON.stringify(["sci-fi, space", "ui", "it's"]));
eq("frontmatter reads a block list", JSON.stringify(f1.meta.formats), JSON.stringify(["PNG", "SVG"]));
const fComment = fm(["tags:", " # content words only", " - low-poly"]);
eq("frontmatter reads a block list after a comment", JSON.stringify(fComment.meta.tags), JSON.stringify(["low-poly"]));
eq("frontmatter has no errors for a list after a comment", fComment.errors.length, 0);
eq("frontmatter reads booleans", f1.meta.commercial, true);
eq("frontmatter has no errors on good input", f1.errors.length, 0);
eq("frontmatter ignores a byte-order mark", parseFrontmatter("---\nid: a\n---\nB")?.meta.id, "a");
Expand Down