From d15e968e3d884e2df5b301cd54654c76c808150b Mon Sep 17 00:00:00 2001 From: kj_sh604 Date: Thu, 19 Feb 2026 21:16:23 -0500 Subject: refactor: go ASCII only mode for now --- src/app.nim | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'src/app.nim') diff --git a/src/app.nim b/src/app.nim index 930e592..80c0502 100644 --- a/src/app.nim +++ b/src/app.nim @@ -233,13 +233,23 @@ proc runPandoc(sourceMarkdown: string; outputPath: string; paperSize: string; ma let tempDir = getTempDir() / (AppName & "-" & randomHex(10)) createDir(tempDir) let tempMarkdownPath = tempDir / "source.md" + let tempRawPath = tempDir / "raw.md" try: - writeFile(tempMarkdownPath, sourceMarkdown) + # write raw markdown first + writeFile(tempRawPath, sourceMarkdown) + + # preprocess markdown: convert to ascii with transliteration and normalize quotes + let iconvCmd = "iconv -c -t ASCII//TRANSLIT " & quoteShell(tempRawPath) & " | sed 's/'\\''/'/g; s/\"\"/\"/g' > " & quoteShell(tempMarkdownPath) + let (iconvOutput, iconvExitCode) = execCmdEx(iconvCmd) + + if iconvExitCode != 0: + # if preprocessing fails, fall back to original content + writeFile(tempMarkdownPath, sourceMarkdown) let args = @[ tempMarkdownPath, - "--from", "markdown+emoji", + "--from", "markdown+emoji+hard_line_breaks", "--pdf-engine=lualatex", "--template", latexTemplatePath(), "-V", "papersize=" & paperSize, @@ -264,6 +274,8 @@ proc runPandoc(sourceMarkdown: string; outputPath: string; paperSize: string; ma return (ok: false, output: output, missingPandoc: false) finally: try: + if fileExists(tempRawPath): + removeFile(tempRawPath) if fileExists(tempMarkdownPath): removeFile(tempMarkdownPath) if dirExists(tempDir): -- cgit v1.2.3