Skip to content
Draft
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
4 changes: 2 additions & 2 deletions src/core/lib/break-quarto-md.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,11 +168,11 @@ export async function breakQuartoMd(
return false;
}

// if a yaml delimiter is surrounded by whitespace-only lines,
// if a yaml delimiter is followed by a whitespace-only line,
// then it is actually an HR element; treat it as such.
// (YAML opening delimiters are followed by content like "key: value")
if (
skipHRs &&
index > 0 && srcLines[index - 1].substring.trim() === "" &&
index < srcLines.length - 1 && srcLines[index + 1].substring.trim() === ""
) {
return false;
Expand Down
35 changes: 35 additions & 0 deletions tests/unit/break-quarto-md/break-quarto-md.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,38 @@ And what about this?
const cells = (await breakQuartoMd(qmd, false)).cells;
assert(cells.length <= 2 || cells[2].cell_type === "markdown");
});

unitTest("break-quarto-md - hr after content (no blank line before)", async () => {
await initYamlIntelligenceResourcesFromFilesystem();
// HR directly after heading, followed by blank line, then more content with another HR later
// The first HR should NOT start a YAML block that consumes content until the second HR
const qmd = `---
title: marimo + quarto
format: html
---

# Heading
---

Some content here.

---

More content.
`;

const cells = (await breakQuartoMd(qmd, false)).cells;

// Check if there's a spurious raw cell after the front matter
const rawCells = cells.filter(cell => cell.cell_type === "raw");

// The HR on line 7 should NOT create a second raw cell
// There should only be 1 raw cell (the front matter)
assert(rawCells.length === 1, `Expected 1 raw cell (front matter only), got ${rawCells.length}`);

// All non-front-matter cells should be markdown
assert(
cells.slice(1).every(cell => cell.cell_type === "markdown"),
"All cells after front matter should be markdown"
);
});
Loading