@@ -489,6 +489,11 @@ protected function inlineMarking(array $Excerpt): ?array
489489 return null ; // Return null if marking or emphasis is disabled
490490 }
491491
492+ // Early return if the excerpt does not start with two '=' characters
493+ if (!isset ($ Excerpt ['text ' ][1 ]) || $ Excerpt ['text ' ][1 ] !== '= ' ) {
494+ return null ;
495+ }
496+
492497 // Match the double equal signs for marking (`==text==`) using regex
493498 if (preg_match ('/^==((?: \\\\\=|[^=]|=[^=]*=)+?)==(?!=)/s ' , $ Excerpt ['text ' ], $ matches )) {
494499 // Return the parsed marking element
@@ -524,6 +529,11 @@ protected function inlineInsertions(array $Excerpt): ?array
524529 return null ; // Return null if insertions or general emphasis is disabled
525530 }
526531
532+ // Early return if the excerpt does not start with two '+' characters
533+ if (!isset ($ Excerpt ['text ' ][1 ]) || $ Excerpt ['text ' ][1 ] !== '+ ' ) {
534+ return null ;
535+ }
536+
527537 // Match the double plus signs for insertions (`++text++`) using regex
528538 if (preg_match ('/^\+\+((?: \\\\\+|[^\+]|\+[^\+]*\+)+?)\+\+(?!\+)/s ' , $ Excerpt ['text ' ], $ matches )) {
529539 // Return the parsed insertion element
@@ -559,6 +569,11 @@ protected function inlineKeystrokes(array $Excerpt): ?array
559569 return null ; // Return null if keystrokes or general emphasis is disabled
560570 }
561571
572+ // Early return if the excerpt does not start with two '[' characters
573+ if (!isset ($ Excerpt ['text ' ][1 ]) || '[ ' !== $ Excerpt ['text ' ][1 ]) {
574+ return null ;
575+ }
576+
562577 // Match the double square brackets for keystrokes (`[[text]]`) using regex
563578 if (preg_match ('/^(?<!\[)\[\[([^\[\]]*|[\[\]])\]\](?!\])/s ' , $ Excerpt ['text ' ], $ matches )) {
564579 // Return the parsed keystroke element
@@ -595,6 +610,11 @@ protected function inlineSuperscript(array $Excerpt): ?array
595610 return null ; // Return null if superscript or general emphasis is disabled
596611 }
597612
613+ // Early return if no text follows the caret
614+ if (!isset ($ Excerpt ['text ' ][1 ]) || '^ ' === $ Excerpt ['text ' ][1 ]) {
615+ return null ;
616+ }
617+
598618 // Match the caret symbols for superscript (`^text^`) using regex
599619 if (preg_match ('/^\^((?: \\\\\\^|[^\^]|\^[^\^]+?\^\^)+?)\^(?!\^)/s ' , $ Excerpt ['text ' ], $ matches )) {
600620 // Return the parsed superscript element
@@ -631,6 +651,11 @@ protected function inlineSubscript(array $Excerpt): ?array
631651 return null ; // Return null if subscript or general emphasis is disabled
632652 }
633653
654+ // Early return if no text follows the tilde or the next character is a tilde
655+ if (!isset ($ Excerpt ['text ' ][1 ]) || '~ ' === $ Excerpt ['text ' ][1 ]) {
656+ return null ;
657+ }
658+
634659 // Match the tilde symbols for subscript (`~text~`) using regex
635660 if (preg_match ('/^~((?: \\\\~|[^~]|~~[^~]*~~)+?)~(?!~)/s ' , $ Excerpt ['text ' ], $ matches )) {
636661 // Return the parsed subscript element
@@ -977,6 +1002,11 @@ protected function inlineEmojis(array $Excerpt): ?array
9771002 return null ; // Return null if emoji replacement is disabled
9781003 }
9791004
1005+ // Early return if there is no closing ':' to form an emoji code
1006+ if (!isset ($ Excerpt ['text ' ][1 ]) || false === strpos ($ Excerpt ['text ' ], ': ' , 1 )) {
1007+ return null ;
1008+ }
1009+
9801010 // Check for an emoji code before loading the large map
9811011 if (!preg_match ('/(?<=\s|^):([a-zA-Z0-9_]+):(?=\s|$)/ ' , $ Excerpt ['text ' ], $ matches ) || !preg_match ('/^(\s|)$/ ' , $ Excerpt ['before ' ])) {
9821012 return null ;
0 commit comments