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.
This commit is contained in:
parent
9f1873d37a
commit
31ca246407
@ -62,7 +62,7 @@
|
|||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@plasmohq/prettier-plugin-sort-imports": "4.0.1",
|
"@plasmohq/prettier-plugin-sort-imports": "4.0.1",
|
||||||
"@types/chrome": "0.0.259",
|
"@types/chrome": "^0.0.280",
|
||||||
"@types/d3-dsv": "^3.0.7",
|
"@types/d3-dsv": "^3.0.7",
|
||||||
"@types/html-to-text": "^9.0.4",
|
"@types/html-to-text": "^9.0.4",
|
||||||
"@types/node": "20.11.9",
|
"@types/node": "20.11.9",
|
||||||
|
19
src/utils/latex.ts
Normal file
19
src/utils/latex.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
export const preprocessLaTeX = (content: string) => {
|
||||||
|
|
||||||
|
let processedContent = content.replace(
|
||||||
|
/\\\[(.*?)\\\]/gs,
|
||||||
|
(_, equation) => `$$${equation}$$`
|
||||||
|
)
|
||||||
|
|
||||||
|
processedContent = processedContent.replace(
|
||||||
|
/\\\((.*?)\\\)/gs,
|
||||||
|
(_, equation) => `$${equation}$`
|
||||||
|
)
|
||||||
|
|
||||||
|
processedContent = processedContent.replace(
|
||||||
|
/\$(\d)/g,
|
||||||
|
'\\$$1'
|
||||||
|
)
|
||||||
|
|
||||||
|
return processedContent
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user