feat: add chinese font support for pandoc
This commit is contained in:
parent
df3330fdc2
commit
c0e1aa524b
3 changed files with 34 additions and 0 deletions
|
|
@ -5,6 +5,7 @@ services:
|
||||||
# dockerfile: Debian.Dockerfile
|
# dockerfile: Debian.Dockerfile
|
||||||
volumes:
|
volumes:
|
||||||
- ./data:/app/data
|
- ./data:/app/data
|
||||||
|
# - /usr/share/fonts/truetype/chinese:/usr/share/fonts/truetype/chinese:ro # mount Chinese fonts from host (optional)
|
||||||
environment: # Defaults are listed below. All are optional.
|
environment: # Defaults are listed below. All are optional.
|
||||||
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
|
- ACCOUNT_REGISTRATION=true # true or false, doesn't matter for the first account (e.g. keep this to false if you only want one account)
|
||||||
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
|
- JWT_SECRET=aLongAndSecretStringUsedToSignTheJSONWebToken1234 # will use randomUUID() by default
|
||||||
|
|
@ -16,5 +17,8 @@ services:
|
||||||
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
# - HIDE_HISTORY=true # hides the history tab in the web interface, defaults to false
|
||||||
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
- TZ=Europe/Stockholm # set your timezone, defaults to UTC
|
||||||
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
|
# - UNAUTHENTICATED_USER_SHARING=true # for use with ALLOW_UNAUTHENTICATED=true to share history with all unauthenticated users / devices
|
||||||
|
# - PANDOC_ENABLE_CHINESE_FONT=true # enable Chinese font support for Pandoc PDF/LaTeX conversion
|
||||||
|
# - PANDOC_CHINESE_FONT_PATH=/usr/share/fonts/truetype/chinese # path to Chinese font directory on host
|
||||||
|
# - PANDOC_CHINESE_FONT_FAMILY=NotoSansCJK # Chinese font family name
|
||||||
ports:
|
ports:
|
||||||
- 3000:3000
|
- 3000:3000
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,10 @@
|
||||||
import { execFile as execFileOriginal } from "node:child_process";
|
import { execFile as execFileOriginal } from "node:child_process";
|
||||||
import { ExecFileFn } from "./types";
|
import { ExecFileFn } from "./types";
|
||||||
|
import {
|
||||||
|
PANDOC_ENABLE_CHINESE_FONT,
|
||||||
|
PANDOC_CHINESE_FONT_PATH,
|
||||||
|
PANDOC_CHINESE_FONT_FAMILY
|
||||||
|
} from "../helpers/env";
|
||||||
|
|
||||||
export const properties = {
|
export const properties = {
|
||||||
from: {
|
from: {
|
||||||
|
|
@ -136,6 +141,24 @@ export function convert(
|
||||||
|
|
||||||
if (xelatex.includes(convertTo)) {
|
if (xelatex.includes(convertTo)) {
|
||||||
args.push("--pdf-engine=xelatex");
|
args.push("--pdf-engine=xelatex");
|
||||||
|
|
||||||
|
// Add Chinese font support if enabled
|
||||||
|
if (PANDOC_ENABLE_CHINESE_FONT) {
|
||||||
|
// Create a custom LaTeX template for Chinese font support
|
||||||
|
const chineseFontArgs = [
|
||||||
|
"-V", `mainfont=${PANDOC_CHINESE_FONT_FAMILY}`,
|
||||||
|
"-V", "CJKmainfont=" + PANDOC_CHINESE_FONT_FAMILY,
|
||||||
|
"--variable", "geometry:margin=1in",
|
||||||
|
"--variable", "fontsize=11pt"
|
||||||
|
];
|
||||||
|
|
||||||
|
// Add font path if specified
|
||||||
|
if (PANDOC_CHINESE_FONT_PATH) {
|
||||||
|
chineseFontArgs.push("--variable", `fontdir:${PANDOC_CHINESE_FONT_PATH}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
args.push(...chineseFontArgs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args.push(filePath);
|
args.push(filePath);
|
||||||
|
|
|
||||||
|
|
@ -23,3 +23,10 @@ export const MAX_CONVERT_PROCESS =
|
||||||
|
|
||||||
export const UNAUTHENTICATED_USER_SHARING =
|
export const UNAUTHENTICATED_USER_SHARING =
|
||||||
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
|
process.env.UNAUTHENTICATED_USER_SHARING?.toLowerCase() === "true" || false;
|
||||||
|
|
||||||
|
export const PANDOC_ENABLE_CHINESE_FONT =
|
||||||
|
process.env.PANDOC_ENABLE_CHINESE_FONT?.toLowerCase() === "true" || false;
|
||||||
|
|
||||||
|
export const PANDOC_CHINESE_FONT_PATH = process.env.PANDOC_CHINESE_FONT_PATH || "";
|
||||||
|
|
||||||
|
export const PANDOC_CHINESE_FONT_FAMILY = process.env.PANDOC_CHINESE_FONT_FAMILY || "SimSun";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue