1 parent cf024f1 commit 4d19b34Copy full SHA for 4d19b34
1 file changed
app/composables/textProcessor.ts
@@ -8,7 +8,7 @@ import { tex2typst } from 'tex2typst'
8
* @returns 包裹后的代码
9
*/
10
export function wrapCode(code: string, wrapOption: string | null): string {
11
- const cleanCode = code.trim()
+ const cleanCode = removeEmptyChars(code.trim())
12
13
if (!wrapOption) {
14
return cleanCode
@@ -41,8 +41,13 @@ export function formatLatex(code: string): string {
41
return new_tokens.join('')
42
}
43
44
+// remove `~` and `\!`
45
+export function removeEmptyChars(code: string) {
46
+ return code.replace(/~/g, '\\ ').replace(/\\!/g, '\\ ')
47
+}
48
+
49
export function convertToTypst(code: string) {
- const cleanedCode = code.replace(/~/g, '\\ ')
50
+ const cleanedCode = removeEmptyChars(code)
51
return tex2typst(cleanedCode)
52
53
0 commit comments