From 31ca246407efd2b4b342292308f66494982e8b70 Mon Sep 17 00:00:00 2001 From: n4ze3m Date: Sun, 3 Nov 2024 23:38:29 +0530 Subject: [PATCH] feat: update LaTeX processing Adds LaTeX processing to the code, enabling the rendering of LaTeX equations within the application. This improves the user experience by allowing users to insert mathematical formulas directly into the content. The LaTeX processing is implemented using a dedicated utility function that replaces LaTeX tags with appropriate MathJax syntax, ensuring seamless rendering. This change is expected to have a positive impact on the overall user experience, making the application more versatile and convenient for users who work with mathematical content. --- bun.lockb | Bin 440402 -> 440402 bytes package.json | 2 +- src/utils/latex.ts | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/utils/latex.ts diff --git a/bun.lockb b/bun.lockb index deaa93f5559b303cdfcdc7f40997e7fbad481eeb..8d4fe90e294d729224c4e4397fe940cc2bf9fa6d 100644 GIT binary patch delta 175 zcmV;g08szZ@EX$a8jvm^-M8C-RnXw4#nL=2pYQ;@@1G-75Iw=IbM+Ej)MNn;fljqf z0g6-s7?VInCzF6h2!{w&0k;TM0$sg80*g|an#=XK84Nj+BT)TxPR|**PP)EJ(ZaD^ z-pHx7V$B7DV~8BS>Q7Ny5a3tCk9Bso-{Lx&CQs2A($BEghouq&x1|yUmU0LJ00000 d0001oLxlu~LxlymLxl$VEdn?&w?DH669vwPOBMhC delta 175 zcmV;g08szZ@EX$a8jvm^443}S$aDVVW$}TFLG$As`}ZI~4m`9Jg<}AXMh3jwfljqf z0g6-s1Cu~SCzF6h2!{w&0k;TM0$sg8Sp7$^x{88@Fh~9!VkF;~4`uZFsuWQVHVAfh{R { + + let processedContent = content.replace( + /\\\[(.*?)\\\]/gs, + (_, equation) => `$$${equation}$$` + ) + + processedContent = processedContent.replace( + /\\\((.*?)\\\)/gs, + (_, equation) => `$${equation}$` + ) + + processedContent = processedContent.replace( + /\$(\d)/g, + '\\$$1' + ) + + return processedContent +}