From 1312094b5b9db87ff6e2223327a074143c8fdcdf Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:30:01 +0300 Subject: [PATCH 1/9] Update markdown.tsx --- app/components/markdown.tsx | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index f3a916cc535..f61db18acf3 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -99,21 +99,11 @@ export function PreCode(props: { children: any }) { ); } -function escapeDollarNumber(text: string) { - let escapedText = ""; - - for (let i = 0; i < text.length; i += 1) { - let char = text[i]; - const nextChar = text[i + 1] || " "; - - if (char === "$" && nextChar >= "0" && nextChar <= "9") { - char = "\\$"; - } - - escapedText += char; - } - - return escapedText; +function escapeDollarNumber(text: string): string { + return text.split('\n').map((line, index, lines) => { + const isInCodeBlock = lines[index - 1]?.trim() === '```' && lines[index + 1]?.trim() === '```'; + return isInCodeBlock ? line : line.replace(/\$\d+([,.](\d+[,.])?\d+)?(?!.*\$\B)/g, '\\$&'); + }).join('\n'); } function _MarkDownContent(props: { content: string }) { From ec1ec93579841032aa9dbd5b0bb7476b3a1cedbd Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:50:34 +0300 Subject: [PATCH 2/9] Update markdown.tsx --- app/components/markdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index f61db18acf3..eaf7c0db4e5 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -102,7 +102,7 @@ export function PreCode(props: { children: any }) { function escapeDollarNumber(text: string): string { return text.split('\n').map((line, index, lines) => { const isInCodeBlock = lines[index - 1]?.trim() === '```' && lines[index + 1]?.trim() === '```'; - return isInCodeBlock ? line : line.replace(/\$\d+([,.](\d+[,.])?\d+)?(?!.*\$\B)/g, '\\$&'); + return isInCodeBlock ? line : line.replace(/(? Date: Thu, 21 Mar 2024 09:49:05 +0300 Subject: [PATCH 3/9] Update markdown.tsx --- app/components/markdown.tsx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index eaf7c0db4e5..3a3b7a541e6 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -100,9 +100,17 @@ export function PreCode(props: { children: any }) { } function escapeDollarNumber(text: string): string { - return text.split('\n').map((line, index, lines) => { - const isInCodeBlock = lines[index - 1]?.trim() === '```' && lines[index + 1]?.trim() === '```'; - return isInCodeBlock ? line : line.replace(/(? { + if (line.trim() === '```') { + isInCodeBlock = !isInCodeBlock; + return line; + } + if (!isInCodeBlock) { + return line.replace(/(? Date: Sat, 23 Mar 2024 03:54:40 +0300 Subject: [PATCH 4/9] Update markdown.tsx --- app/components/markdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 3a3b7a541e6..59091666e78 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -107,7 +107,7 @@ function escapeDollarNumber(text: string): string { return line; } if (!isInCodeBlock) { - return line.replace(/(? Date: Sat, 23 Mar 2024 03:58:24 +0300 Subject: [PATCH 5/9] Update markdown.tsx --- app/components/markdown.tsx | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 59091666e78..0c08024da4e 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -100,13 +100,13 @@ export function PreCode(props: { children: any }) { } function escapeDollarNumber(text: string): string { - let isInCodeBlock = false; + let isInCode = false; return text.split('\n').map(line => { - if (line.trim() === '```') { - isInCodeBlock = !isInCodeBlock; + if (line.trim() === '```' || line.trim() === '`') { + isInCode = !isInCode; return line; } - if (!isInCodeBlock) { + if (!isInCode) { return line.replace(/(? Date: Sat, 23 Mar 2024 05:37:10 +0300 Subject: [PATCH 6/9] Update markdown.tsx --- app/components/markdown.tsx | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 0c08024da4e..a78770c8e9f 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -100,14 +100,20 @@ export function PreCode(props: { children: any }) { } function escapeDollarNumber(text: string): string { - let isInCode = false; + let isInMultilineCode = false; return text.split('\n').map(line => { if (line.trim() === '```' || line.trim() === '`') { - isInCode = !isInCode; + isInMultilineCode = !isInMultilineCode; return line; } - if (!isInCode) { - return line.replace(/(? { + if (inlineCode) { + return inlineCode; + } else { + return `\\${number}`; + } + }); } else { return line; } From be25164037c4c97c25316e1d3f6267c94d3c56cf Mon Sep 17 00:00:00 2001 From: Algorithm5838 <108630393+Algorithm5838@users.noreply.github.com> Date: Sat, 23 Mar 2024 06:31:44 +0300 Subject: [PATCH 7/9] Update markdown.tsx --- app/components/markdown.tsx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index a78770c8e9f..56d1e3cfd4a 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -100,20 +100,20 @@ export function PreCode(props: { children: any }) { } function escapeDollarNumber(text: string): string { - let isInMultilineCode = false; + let isInBlockCode = false; return text.split('\n').map(line => { if (line.trim() === '```' || line.trim() === '`') { - isInMultilineCode = !isInMultilineCode; + isInBlockCode = !isInBlockCode; return line; } - if (!isInMultilineCode) { - return line.replace(/(`[^`]*`)|(\$[0-9]+(?:[,.][0-9]+)*)/g, (match, inlineCode, number) => { - if (inlineCode) { - return inlineCode; + if (!isInBlockCode) { + return line.split(/(`.*?`)/g).map((segment, index) => { + if (index % 2 === 0) { + return segment.replace(/(? Date: Sat, 23 Mar 2024 07:02:02 +0300 Subject: [PATCH 8/9] Update markdown.tsx --- app/components/markdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index 56d1e3cfd4a..d730036092c 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -109,7 +109,7 @@ function escapeDollarNumber(text: string): string { if (!isInBlockCode) { return line.split(/(`.*?`)/g).map((segment, index) => { if (index % 2 === 0) { - return segment.replace(/(? Date: Tue, 26 Mar 2024 07:06:35 +0300 Subject: [PATCH 9/9] Update markdown.tsx --- app/components/markdown.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/markdown.tsx b/app/components/markdown.tsx index d730036092c..e36867ba132 100644 --- a/app/components/markdown.tsx +++ b/app/components/markdown.tsx @@ -109,7 +109,7 @@ function escapeDollarNumber(text: string): string { if (!isInBlockCode) { return line.split(/(`.*?`)/g).map((segment, index) => { if (index % 2 === 0) { - return segment.replace(/(?