@bendyline/gezel 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1445,6 +1445,14 @@ function cleanHeading(text) {
1445
1445
  function documentH1s(markdown) {
1446
1446
  return [...markdown.matchAll(/^#\s+(.+?)\s*$/gm)].map((match) => match[1].trim());
1447
1447
  }
1448
+ function documentH2s(markdown) {
1449
+ return [...markdown.matchAll(/^##\s+(.+?)\s*$/gm)].map((match) => match[1].trim());
1450
+ }
1451
+ function headingLevelHint(file, documentHeadings, h2s, expected) {
1452
+ if (documentHeadings.length > 1 || h2s.length !== expected || expected === 0) return null;
1453
+ const title = documentHeadings.length === 1 ? ` and \`# ${documentHeadings[0]}\` as a title` : "";
1454
+ return `${file} puts its ${expected} slides at \`##\`${title}, but slides are split on H1 \u2014 as written this converts to a single slide. Promote each \`## Slide\` heading to \`# \` and drop the document title.`;
1455
+ }
1448
1456
  function outlineSlideHeadings(markdown) {
1449
1457
  const headings = [];
1450
1458
  for (const match of markdown.matchAll(/^#{2,6}\s+(.+?)\s*$/gm)) {
@@ -1483,9 +1491,10 @@ async function markdownHeadingsMatch(ws, file, outlineFile) {
1483
1491
  };
1484
1492
  }
1485
1493
  if (actual.length !== expected.length) {
1494
+ const levelHint = headingLevelHint(file, actual, documentH2s(document), expected.length);
1486
1495
  return {
1487
1496
  ok: false,
1488
- detail: `${file} has ${actual.length} H1 slide headings, but ${outlineFile} locks ${expected.length}. Add or remove slides without merging outline items.`,
1497
+ detail: levelHint ?? `${file} has ${actual.length} H1 slide headings, but ${outlineFile} locks ${expected.length}. Add or remove slides without merging outline items.`,
1489
1498
  outlineHeadings: expected,
1490
1499
  documentHeadings: actual
1491
1500
  };