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

View File

@@ -231,9 +231,17 @@ const RenderInlineInternal: React.FC<RenderInlineProps> = ({ text }) => {
</Text>
);
} else if (
fullMatch.length > ITALIC_MARKER_LENGTH * 2 &&
((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 = (
<Text key={key} italic>