Skip to content

Commit 4d19b34

Browse files
alephpiCopilot
andcommitted
fix: #18
Co-authored-by: Copilot <copilot@github.com>
1 parent cf024f1 commit 4d19b34

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

app/composables/textProcessor.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { tex2typst } from 'tex2typst'
88
* @returns 包裹后的代码
99
*/
1010
export function wrapCode(code: string, wrapOption: string | null): string {
11-
const cleanCode = code.trim()
11+
const cleanCode = removeEmptyChars(code.trim())
1212

1313
if (!wrapOption) {
1414
return cleanCode
@@ -41,8 +41,13 @@ export function formatLatex(code: string): string {
4141
return new_tokens.join('')
4242
}
4343

44+
// remove `~` and `\!`
45+
export function removeEmptyChars(code: string) {
46+
return code.replace(/~/g, '\\ ').replace(/\\!/g, '\\ ')
47+
}
48+
4449
export function convertToTypst(code: string) {
45-
const cleanedCode = code.replace(/~/g, '\\ ')
50+
const cleanedCode = removeEmptyChars(code)
4651
return tex2typst(cleanedCode)
4752
}
4853

0 commit comments

Comments
 (0)