Stop a banner rule from being read as a section heading
Three # rules open most docs here, so the title became a section too small to survive and the paragraph defining the project got a chunk with no heading.
This commit is contained in:
+16
-1
@@ -149,7 +149,22 @@ function sectionsFromMarkdown(text) {
|
||||
for (let i = 0; i < lines.length; i++) {
|
||||
if (/^\s*```/.test(lines[i])) { fence = !fence; continue; }
|
||||
if (fence) continue;
|
||||
if (/^#{1,3}\s+\S/.test(lines[i])) marks.push(i);
|
||||
// A heading whose text is nothing but rule characters is a banner, not a section. The
|
||||
// house style opens a document with three of them —
|
||||
// # ━━━━━━━━
|
||||
// # 🏠 VARAVERK
|
||||
// # ━━━━━━━━
|
||||
// — and treating each as a boundary split the title into a section of its own, too small
|
||||
// to survive, then gave the paragraph that actually defines the project a chunk headed by
|
||||
// the rule beneath it: no heading, and content opening with 75 identical glyphs. That is
|
||||
// why "what is Varaverk" returned five script PURPOSE headers and never README.md, which
|
||||
// has been indexed the whole time. 35 of the 40 markdown files here open this way.
|
||||
//
|
||||
// Whole-string test, so an ordinary heading containing a dash is unaffected — "Set-up"
|
||||
// does not reduce to empty, and a line of dashes does.
|
||||
if (!/^#{1,3}\s+\S/.test(lines[i])) continue;
|
||||
if (lines[i].replace(/^#+\s*/, '').replace(/[━─═=~_*\-\s]+/gu, '') === '') continue;
|
||||
marks.push(i);
|
||||
}
|
||||
if (!marks.length) return [{ heading: null, content: text.trim() }];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user