From fae2ba9c54461dccdccd1bfb5e76398540d11d0b Mon Sep 17 00:00:00 2001 From: C4illin Date: Thu, 27 Jun 2024 23:26:46 +0200 Subject: [PATCH] feat: change to xelatex --- Dockerfile | 1 + README.md | 2 +- src/converters/main.ts | 12 ++++++------ src/converters/pandoc.ts | 8 +++++++- src/converters/{pdflatex.ts => xelatex.ts} | 2 +- 5 files changed, 16 insertions(+), 9 deletions(-) rename src/converters/{pdflatex.ts => xelatex.ts} (90%) diff --git a/Dockerfile b/Dockerfile index dda7415..ea4c124 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,7 @@ LABEL repo="https://github.com/C4illin/ConvertX" RUN apk --no-cache add \ pandoc \ texlive \ + texlive-xetex \ texmf-dist-latexextra \ ffmpeg \ graphicsmagick \ diff --git a/README.md b/README.md index 656f619..0906ce1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ A self-hosted online file converter. Supports 831 different formats. Written wit |------------------------------------------------------------------------------|---------------|---------------|-------------| | [libjxl](https://github.com/libjxl/libjxl) | JPEG XL | 11 | 11 | | [Vips](https://github.com/libvips/libvips) | Images | 45 | 23 | -| [PDFLaTeX](https://www.math.rug.nl/~trentelman/jacob/pdflatex/pdflatex.html) | Documents | 1 | 1 | +| [XeLaTeX](https://tug.org/xetex/) | Documents | 1 | 1 | | [Pandoc](https://pandoc.org/) | Documents | 43 | 65 | | [GraphicsMagick](http://www.graphicsmagick.org/) | Images | 166 | 133 | | [FFmpeg](https://ffmpeg.org/) | Video | ~473 | ~280 | diff --git a/src/converters/main.ts b/src/converters/main.ts index e2cbcb3..13028ca 100644 --- a/src/converters/main.ts +++ b/src/converters/main.ts @@ -16,9 +16,9 @@ import { } from "./graphicsmagick"; import { - convert as convertPdflatex, - properties as propertiesPdflatex, -} from "./pdflatex"; + convert as convertxelatex, + properties as propertiesxelatex, +} from "./xelatex"; import { convert as convertLibjxl, @@ -63,9 +63,9 @@ const properties: { properties: propertiesImage, converter: convertImage, }, - pdflatex: { - properties: propertiesPdflatex, - converter: convertPdflatex, + xelatex: { + properties: propertiesxelatex, + converter: convertxelatex, }, pandoc: { properties: propertiesPandoc, diff --git a/src/converters/pandoc.ts b/src/converters/pandoc.ts index 875e4d9..c86a9e0 100644 --- a/src/converters/pandoc.ts +++ b/src/converters/pandoc.ts @@ -127,9 +127,15 @@ export function convert( // biome-ignore lint/suspicious/noExplicitAny: options?: any, ): Promise { + // set xelatex here + const xelatex = ["pdf", "latex"]; + let option = ""; + if (xelatex.includes(convertTo)) { + option = "--pdf-engine=xelatex"; + } return new Promise((resolve, reject) => { exec( - `pandoc "${filePath}" -f ${fileType} -t ${convertTo} -o "${targetPath}"`, + `pandoc ${option} "${filePath}" -f ${fileType} -t ${convertTo} -o "${targetPath}"`, (error, stdout, stderr) => { if (error) { reject(`error: ${error}`); diff --git a/src/converters/pdflatex.ts b/src/converters/xelatex.ts similarity index 90% rename from src/converters/pdflatex.ts rename to src/converters/xelatex.ts index 324e9bb..2496785 100644 --- a/src/converters/pdflatex.ts +++ b/src/converters/xelatex.ts @@ -25,7 +25,7 @@ export function convert( .join("/") .replace("./", ""); exec( - `pdflatex -interaction=nonstopmode -output-directory="${outputPath}" "${filePath}"`, + `latexmk -xelatex -interaction=nonstopmode -output-directory="${outputPath}" "${filePath}"`, (error, stdout, stderr) => { if (error) { reject(`error: ${error}`);