Skip to content

Commit 9c180ba

Browse files
authored
Add inline documentation
1 parent ecfa3c5 commit 9c180ba

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

index.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,33 @@ class MarkdownToc {
5050
let level = NaN;
5151
let title = null;
5252

53+
// Check for:
54+
// 1. ATX-style headers: ## My Header
55+
//
56+
// 2. Setext-style headers:
57+
// a) Level 1 header: My Header
58+
// =========
59+
//
60+
// b) Level 2 header: My Header
61+
// ---------
62+
//
63+
// Edge cases that do not count as headers:
64+
// i) Horizontal rule ("Underline" preceded by empty line):
65+
//
66+
// Some paragraph 1
67+
// <empty line>
68+
// -----
69+
// Some paragraph 2
70+
//
71+
// ii) Two or more horizontal rules:
72+
//
73+
// Some paragraph 1
74+
//
75+
// -----
76+
// -----
77+
// -----
78+
// Some paragraph 2
79+
5380
if (trimmed.startsWith("#")) {
5481
const match = trimmed.match(/(#+)\s*(.*?)#*\s*$/);
5582
level = match[1].length;

0 commit comments

Comments
 (0)