more strict italics: delimiters cannot be preceded/followed by \w or [./\\]\S (#677)

This commit is contained in:
Olcan 2025-06-01 16:52:31 -07:00 committed by GitHub
parent 2828fc6d66
commit d009267801
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 1 deletions

View File

@ -231,9 +231,17 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
</Text> </Text>
); );
} else if ( } else if (
fullMatch.length > ITALIC_MARKER_LENGTH * 2 &&
((fullMatch.startsWith('*') && fullMatch.endsWith('*')) || ((fullMatch.startsWith('*') && fullMatch.endsWith('*')) ||
(fullMatch.startsWith('_') && fullMatch.endsWith('_'))) && (fullMatch.startsWith('_') && fullMatch.endsWith('_'))) &&
fullMatch.length > ITALIC_MARKER_LENGTH * 2 !/\w/.test(text.substring(match.index - 1, match.index)) &&
!/\w/.test(
text.substring(inlineRegex.lastIndex, inlineRegex.lastIndex + 1),
) &&
!/\S[./\\]/.test(text.substring(match.index - 2, match.index)) &&
!/[./\\]\S/.test(
text.substring(inlineRegex.lastIndex, inlineRegex.lastIndex + 2),
)
) { ) {
renderedNode = ( renderedNode = (
<Text key={key} italic> <Text key={key} italic>