@@ -296,7 +296,7 @@ const TABLE_RIGHT_ALIGN = /^ *-+: *$/
296
296
* and therefore miss content that should have been included.
297
297
*/
298
298
const INLINE_SKIP_R =
299
- '((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|~~.*?~~|==.*?==|.|\\n)* ?)'
299
+ '((?:\\[.*?\\][([].*?[)\\]]|<.*?>(?:.*?<.*?>)?|`.*?`|\\\\\\1|[\\s\\S])+ ?)'
300
300
301
301
/**
302
302
* Detect a sequence like **foo** or __foo__. Note that bold has a higher priority
@@ -307,17 +307,17 @@ const TEXT_BOLD_R = new RegExp(`^([*_])\\1${INLINE_SKIP_R}\\1\\1(?!\\1)`)
307
307
/**
308
308
* Detect a sequence like *foo* or _foo_.
309
309
*/
310
- const TEXT_EMPHASIZED_R = new RegExp ( `^([*_])${ INLINE_SKIP_R } \\1(?!\\1|\\w )` )
310
+ const TEXT_EMPHASIZED_R = new RegExp ( `^([*_])${ INLINE_SKIP_R } \\1(?!\\1)` )
311
311
312
312
/**
313
313
* Detect a sequence like ==foo==.
314
314
*/
315
- const TEXT_MARKED_R = new RegExp ( `^== ${ INLINE_SKIP_R } == ` )
315
+ const TEXT_MARKED_R = new RegExp ( `^(==) ${ INLINE_SKIP_R } \\1 ` )
316
316
317
317
/**
318
318
* Detect a sequence like ~~foo~~.
319
319
*/
320
- const TEXT_STRIKETHROUGHED_R = new RegExp ( `^~~ ${ INLINE_SKIP_R } ~~ ` )
320
+ const TEXT_STRIKETHROUGHED_R = new RegExp ( `^(~~) ${ INLINE_SKIP_R } \\1 ` )
321
321
322
322
const TEXT_ESCAPED_R = / ^ \\ ( [ ^ 0 - 9 A - Z a - z \s ] ) /
323
323
const TEXT_UNESCAPE_R = / \\ ( [ ^ 0 - 9 A - Z a - z \s ] ) / g
@@ -575,6 +575,10 @@ const BLOCK_SYNTAXES = [
575
575
HTML_SELF_CLOSING_ELEMENT_R ,
576
576
]
577
577
578
+ function trimEnd ( str : string ) {
579
+ return str . replace ( / \s * $ / , '' )
580
+ }
581
+
578
582
function containsBlockSyntax ( input : string ) {
579
583
return BLOCK_SYNTAXES . some ( r => r . test ( input ) )
580
584
}
@@ -979,12 +983,14 @@ function matchParagraph(source: string, state: MarkdownToJSX.State) {
979
983
return ! ! line . trim ( )
980
984
} )
981
985
982
- const captured = match . trimEnd ( )
986
+ const captured = trimEnd ( match )
983
987
if ( captured == '' ) {
984
988
return null
985
989
}
986
990
987
- return [ match , captured ]
991
+ // parseCaptureInline expects the inner content to be at index 2
992
+ // because index 1 is the delimiter for text formatting syntaxes
993
+ return [ match , , captured ]
988
994
}
989
995
990
996
export function sanitizer ( url : string ) : string {
@@ -1074,7 +1080,7 @@ const parseCaptureInline: MarkdownToJSX.Parser<{
1074
1080
children : MarkdownToJSX . ParserResult [ ]
1075
1081
} > = ( capture , parse , state : MarkdownToJSX . State ) => {
1076
1082
return {
1077
- children : parseInline ( parse , capture [ 1 ] , state ) ,
1083
+ children : parseInline ( parse , capture [ 2 ] , state ) ,
1078
1084
}
1079
1085
}
1080
1086
@@ -1225,7 +1231,7 @@ export function compiler(
1225
1231
parser (
1226
1232
inline
1227
1233
? input
1228
- : `${ input . trimEnd ( ) . replace ( TRIM_STARTING_NEWLINES , '' ) } \n\n` ,
1234
+ : `${ trimEnd ( input ) . replace ( TRIM_STARTING_NEWLINES , '' ) } \n\n` ,
1229
1235
{
1230
1236
inline,
1231
1237
}
0 commit comments