@@ -12,8 +12,16 @@ import {
1212} from '..' ;
1313import { TransformOptions , Header , HeaderWithRepetition , HeaderWithAnchor , SectionInfo , TransformResult } from '../types' ;
1414
15- export const matchesStart = ( openingComment ?: string ) => ( line : string ) : boolean => ( new RegExp ( openingComment ? openingComment : CHECK_OPENING_COMMENT ) ) . test ( line ) ;
16- export const matchesEnd = ( closingComment ?: string ) => ( line : string ) : boolean => ( new RegExp ( closingComment ? closingComment : CHECK_CLOSING_COMMENT ) ) . test ( line ) ;
15+ const getTargetComments = ( checkComments : Array < string > , defaultComments : string ) : Array < string > => {
16+ if ( checkComments . length ) {
17+ return checkComments ;
18+ }
19+
20+ return [ defaultComments ] ;
21+ } ;
22+
23+ export const matchesStart = ( checkOpeningComments ?: Array < string > ) => ( line : string ) : boolean => getTargetComments ( checkOpeningComments ?? [ ] , CHECK_OPENING_COMMENT ) . some ( comment => new RegExp ( comment ) . test ( line ) ) ;
24+ export const matchesEnd = ( checkClosingComments ?: Array < string > ) => ( line : string ) : boolean => getTargetComments ( checkClosingComments ?? [ ] , CHECK_CLOSING_COMMENT ) . some ( comment => new RegExp ( comment ) . test ( line ) ) ;
1725const addAnchor = ( mode : string | undefined , moduleName : string | undefined , header : HeaderWithRepetition ) : HeaderWithAnchor => {
1826 return {
1927 ...header ,
@@ -120,8 +128,8 @@ export const transform = (
120128 updateOnly,
121129 openingComment,
122130 closingComment,
123- checkOpeningComment ,
124- checkClosingComment ,
131+ checkOpeningComments ,
132+ checkClosingComments ,
125133 } : TransformOptions = { } ,
126134) : TransformResult => {
127135 mode = mode || 'github.com' ;
@@ -131,7 +139,7 @@ export const transform = (
131139 // eslint-disable-next-line no-magic-numbers
132140 const maxHeaderLevelHtml = maxHeaderLevel || 4 ;
133141 const lines = content . split ( '\n' ) ;
134- const info : SectionInfo = updateSection . parse ( lines , matchesStart ( checkOpeningComment ) , matchesEnd ( checkClosingComment ) ) ;
142+ const info : SectionInfo = updateSection . parse ( lines , matchesStart ( checkOpeningComments ) , matchesEnd ( checkClosingComments ) ) ;
135143
136144 if ( ! info . hasStart && updateOnly ) {
137145 return {
@@ -185,7 +193,7 @@ export const transform = (
185193
186194 return {
187195 transformed : true ,
188- data : updateSection ( lines . join ( '\n' ) , wrappedToc , matchesStart ( checkOpeningComment ) , matchesEnd ( checkClosingComment ) , true ) ,
196+ data : updateSection ( lines . join ( '\n' ) , wrappedToc , matchesStart ( checkOpeningComments ) , matchesEnd ( checkClosingComments ) , true ) ,
189197 toc,
190198 wrappedToc,
191199 reason : '' ,
0 commit comments