Download src/converters/xelatex.ts from linuxrun/convert: direct link, hf CLI and curl.
- Browser
- Download file 1.06 kB
-
https://huggingface.co/spaces/linuxrun/convert/resolve/main/src/converters/xelatex.ts
- Command line
-
hf download hf://spaces/linuxrun/convert/src/converters/xelatex.ts
-
curl -L -o xelatex.ts https://huggingface.co/spaces/linuxrun/convert/resolve/main/src/converters/xelatex.ts
1.06 kB
| import { execFile as execFileOriginal } from "node:child_process"; | |
| import { ExecFileFn } from "./types"; | |
| export const properties = { | |
| from: { | |
| text: ["tex", "latex"], | |
| }, | |
| to: { | |
| text: ["pdf"], | |
| }, | |
| }; | |
| export function convert( | |
| filePath: string, | |
| fileType: string, | |
| convertTo: string, | |
| targetPath: string, | |
| options?: unknown, | |
| execFile: ExecFileFn = execFileOriginal, | |
| ): Promise<string> { | |
| return new Promise((resolve, reject) => { | |
| // const fileName: string = (targetPath.split("/").pop() as string).replace(".pdf", "") | |
| const outputPath = targetPath.split("/").slice(0, -1).join("/").replace("./", ""); | |
| execFile( | |
| "latexmk", | |
| ["-xelatex", "-interaction=nonstopmode", `-output-directory=${outputPath}`, filePath], | |
| (error, stdout, stderr) => { | |
| if (error) { | |
| reject(`error: ${error}`); | |
| } | |
| if (stdout) { | |
| console.log(`stdout: ${stdout}`); | |
| } | |
| if (stderr) { | |
| console.error(`stderr: ${stderr}`); | |
| } | |
| resolve("Done"); | |
| }, | |
| ); | |
| }); | |
| } | |