File tree Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Expand file tree Collapse file tree 1 file changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -50,6 +50,33 @@ class MarkdownToc {
50
50
let level = NaN ;
51
51
let title = null ;
52
52
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
+
53
80
if ( trimmed . startsWith ( "#" ) ) {
54
81
const match = trimmed . match ( / ( # + ) \s * ( .* ?) # * \s * $ / ) ;
55
82
level = match [ 1 ] . length ;
You can’t perform that action at this time.
0 commit comments