@@ -203,28 +203,39 @@ export function parseCommentString(
203
203
// Check for frontmatter
204
204
let frontmatterData : Record < string , unknown > = { } ;
205
205
const firstBlock = content [ 0 ] ;
206
- if ( firstBlock . text . startsWith ( "---\n" ) ) {
207
- const end = firstBlock . text . indexOf ( "\n---\n" ) ;
206
+
207
+ let lineBreak : string ;
208
+ switch ( firstBlock . text . startsWith ( "---\r\n" ) ) {
209
+ case true :
210
+ lineBreak = "\r\n" ;
211
+ break ;
212
+ case false :
213
+ lineBreak = "\n" ;
214
+ break ;
215
+ }
216
+
217
+ if ( firstBlock . text . startsWith ( `---${ lineBreak } ` ) ) {
218
+ const end = firstBlock . text . indexOf ( `${ lineBreak } ---${ lineBreak } ` ) ;
208
219
if ( end !== - 1 ) {
209
- const yamlText = firstBlock . text . slice ( " ---\n" . length , end ) ;
220
+ const yamlText = firstBlock . text . slice ( ` ---${ lineBreak } ` . length , end ) ;
210
221
firstBlock . text = firstBlock . text
211
- . slice ( end + "\n ---\n" . length )
222
+ . slice ( end + ` ${ lineBreak } ---${ lineBreak } ` . length )
212
223
. trimStart ( ) ;
213
224
214
225
const frontmatter = parseYamlDoc ( yamlText , { prettyErrors : false } ) ;
215
226
for ( const warning of frontmatter . warnings ) {
216
227
// Can't translate issues coming from external library...
217
228
logger . warn (
218
229
warning . message as TranslatedString ,
219
- warning . pos [ 0 ] + " ---\n" . length ,
230
+ warning . pos [ 0 ] + ` ---${ lineBreak } ` . length ,
220
231
file ,
221
232
) ;
222
233
}
223
234
for ( const error of frontmatter . errors ) {
224
235
// Can't translate issues coming from external library...
225
236
logger . error (
226
237
error . message as TranslatedString ,
227
- error . pos [ 0 ] + " ---\n" . length ,
238
+ error . pos [ 0 ] + ` ---${ lineBreak } ` . length ,
228
239
file ,
229
240
) ;
230
241
}
0 commit comments