File tree 1 file changed +16
-1
lines changed
1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,8 @@ function cleanLine(line: string) {
66
66
. trim ( ) ;
67
67
}
68
68
69
+ const IGNORE_LINE_PREFIXES = [ '>' , '---' , '|' ] ;
70
+
69
71
export function parseSections ( content : string ) : ParsedSection [ ] {
70
72
const res = [ ] ;
71
73
const section : ParsedSection = {
@@ -74,10 +76,23 @@ export function parseSections(content: string): ParsedSection[] {
74
76
headline : '' ,
75
77
} ;
76
78
79
+ let withinPreamble = false ;
80
+ let index = 0 ;
77
81
for ( const line of content . split ( '\n' ) ) {
78
82
const cleanedLine = cleanLine ( line ) ;
79
83
80
- if ( line . startsWith ( '>' ) ) {
84
+ if ( line . startsWith ( '---' ) ) {
85
+ if ( index === 0 ) {
86
+ withinPreamble = true ;
87
+ } else if ( withinPreamble ) {
88
+ withinPreamble = false ;
89
+ }
90
+ }
91
+
92
+ index ++ ;
93
+
94
+ const startsWithIgnorePrefix = IGNORE_LINE_PREFIXES . some ( ( prefix ) => line . startsWith ( prefix ) ) ;
95
+ if ( withinPreamble || startsWithIgnorePrefix ) {
81
96
continue ;
82
97
}
83
98
You can’t perform that action at this time.
0 commit comments