Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions make-pdf/src/print-css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
// Metric-compatible sans stack: Helvetica (macOS), Liberation Sans (Linux,
// ships via fonts-liberation), Arial (Windows). Shared by every text surface.
const SANS_STACK = `Helvetica, "Liberation Sans", Arial`;
// CJK fallback families, appended to the body stack only.
const CJK_STACK = `"Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Microsoft YaHei"`;
// CJK fallback families (Simplified-Chinese first), appended to the body stack only.
const CJK_STACK = `"PingFang SC", "Heiti SC", "Noto Sans CJK SC", "Source Han Sans SC", "Microsoft YaHei", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP"`;
// Color-emoji families: Apple (macOS), Segoe (Windows), Noto (Linux).
const EMOJI_FAMILIES = `"Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji"`;

Expand Down
8 changes: 4 additions & 4 deletions make-pdf/src/smartypants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

const CODE_ZONE_RE = /<(pre|code|script|style)\b[^>]*>[\s\S]*?<\/\1>/gi;
const TAG_RE = /<[^>]+>/g;
const URL_RE = /\bhttps?:\/\/\S+/g;
const URL_RE = /\bhttps?:\/\/[^\s\u0000]+/g;

/**
* Apply smartypants to an HTML string. Zones that should not be touched:
Expand All @@ -44,7 +44,7 @@ export function smartypants(html: string): string {
});
};

let s = html;
let s = html.replace(/\u0000/g, ""); // drop stray input NUL (can't forge a placeholder)
s = carve(s, CODE_ZONE_RE);
s = carve(s, TAG_RE);
s = carve(s, URL_RE);
Expand Down Expand Up @@ -89,11 +89,11 @@ function transformText(text: string): string {

// Double quotes: open if preceded by whitespace/bol, close if preceded
// by word char or punctuation.
s = s.replace(/(^|[\s\(\[\{\-])"/g, "$1\u201c"); // opening "
s = s.replace(/(^|[\s\(\[\{\-:(【「『〈《])"/g, "$1\u201c"); // opening "
s = s.replace(/"/g, "\u201d"); // remaining " are closing

// Single quotes (after apostrophe pass):
s = s.replace(/(^|[\s\(\[\{\-])'/g, "$1\u2018"); // opening '
s = s.replace(/(^|[\s\(\[\{\-:(【「『〈《])'/g, "$1\u2018"); // opening '
s = s.replace(/'/g, "\u2019"); // remaining ' are closing

return s;
Expand Down