import { ImagePathRecognizer , UrlMatch } from './recognizer' ; import { acceptedExtensions } from '../util/acceptedExtensions' ; export const siblingRecognizer = { recognize : ( lineIndex , line ) : UrlMatch [ ] => { const excludedPathCharactersClause = '[^\\0\\s!$`&*()\\[\\]+\'":;\\\\]' ; let pattern = new RegExp ( `(${ excludedPathCharactersClause }+[${ acceptedExtensions . map ( ( p ) => `(\\${ p })` ) . join ( '|' ) }])` , 'ig' ) ; let match ; const result = [ ] ; while ( ( match = pattern . exec ( line ) ) ) { if ( match . length > 0 ) { const imagePath = match [ 0 ] ; result . push ( { url : imagePath , lineIndex , start : match . index , end : match . index + imagePath . length , } ) ; } } return result ; } , } ;