File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -22,16 +22,16 @@ export const createRegexRenderer = (
22
22
| [
23
23
regex : RegExp ,
24
24
style : StyleOrRender ,
25
- shouldRender ?: ( matchedText : string ) => boolean ,
25
+ shouldRender ?: ( matchedText : string , matchResult : RegExpExecArray ) => boolean ,
26
26
]
27
27
) [ ]
28
28
) : Renderer => {
29
29
const allStyles = matchers . map ( ( [ , style ] ) => style ) ;
30
30
31
31
return ( value ) => {
32
32
const [ indexSet , startToStyleMap , endToStyleMap ] = matchers . reduce (
33
- ( acc , [ matcher , style , shouldRender ] ) => {
34
- execReg ( matcher , value , shouldRender ) . forEach ( ( m ) => {
33
+ ( acc , [ regex , style , shouldRender ] ) => {
34
+ execReg ( regex , value , shouldRender ) . forEach ( ( m ) => {
35
35
const start = m . index ;
36
36
const end = m . index + m [ 0 ] ! . length ;
37
37
Original file line number Diff line number Diff line change 4
4
export const execReg = (
5
5
reg : RegExp ,
6
6
text : string ,
7
- shouldRender ?: ( matchedText : string ) => boolean
7
+ shouldRender ?: ( matchedText : string , matchResult : RegExpExecArray ) => boolean
8
8
) : RegExpExecArray [ ] => {
9
9
const results : RegExpExecArray [ ] = [ ] ;
10
10
let match : RegExpExecArray | null = null ;
11
11
while ( ( match = reg . exec ( text ) ) ) {
12
- if ( shouldRender && ! shouldRender ( text ) ) {
12
+ if ( shouldRender && ! shouldRender ( text , match ) ) {
13
13
continue ;
14
14
}
15
15
results . push ( match ) ;
You can’t perform that action at this time.
0 commit comments