/ccxp-skills:md-to-pdf <path-to-md> [--img-width 60] [--output path.pdf] [--extra-css path]from ccxp-skills
Convert markdown to PDF with scaled images, preserved line breaks, and CJK/special character support
Ships in ccxp-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Convert a markdown file to a well-formatted PDF. Handles documents that may mix English and CJK (e.g. Chinese legal documents, bilingual notes, mostly-English memos with occasional CJK).
.md becomes a line break in the PDF (not joined into a paragraph)↔) forced to Apple Symbols so they never hit the .LastResort boxed-"?" glyphtr { break-inside: avoid } in the default CSS. A row that doesn't fit on the current page moves to the next page whole rather than splitting mid-row. <thead> still repeats on every page a table spans (browser/weasyprint default table layout behavior).$ARGUMENTS contains:
.md file (relative or absolute). If omitted, prompt the user.--img-width N — max image width as % of page (default: 60)--output path.pdf — output path (default: same name as input with .pdf extension, same directory)--extra-css <path> — path to an additional CSS file appended after the default CSS in step 4's <style> block (optional; lets callers like translate-patent extend/override without forking this skill).md path. Verify the file exists.--img-width (default 60), --output (default: replace .md → .pdf), and --extra-css (default: none).--extra-css is given, verify that file exists (fail fast, same as the .md input check).Create a temporary copy of the markdown file with these fixes applied:
a) Fix special characters:
""'') with straight quotes (", '), 。 : ; ? ! — leave them as-is if they're correct; fix mojibake if present)b) Wrap stack-uncovered symbols (macOS .LastResort workaround):
On macOS, fontconfig's .LastResort font claims ALL codepoints, so a symbol missing from every named font in the CSS stack renders as a boxed "?" — even if a later font in the stack covers it (.LastResort outranks it in fontconfig's per-glyph sort). Known case: ↔ U+2194 — Helvetica has no arrows, and the GB-charset CJK fonts (Hiragino Sans GB / PingFang SC) cover ←↑→↓ but NOT ↔.
Fix in preprocessing by wrapping such characters in an explicit single-font span (verified: Apple Symbols covers them and renders correctly when named alone):
import re
text = re.sub(r'[↔⇄⇆⇌⇋⟷∈∉∀∃⊕⊗≡∴∵]',
lambda m: f'<span style="font-family: Apple Symbols">{m.group(0)}</span>', text)
Do NOT wrap chars already covered by the stack: — × ①②③ § ≠ ≤ ≥ → ← ↑ ↓ ¥ and emoji (Apple Color Emoji handles those).
Skip this replacement inside fenced code blocks (raw HTML would show literally).
Step 7's pdffonts .LastResort check is the authoritative verification — if it still appears, scan the source for the culprit char and add it to this wrap list.
pandoc +emoji gotcha: pandoc's emoji extension appends an invisible U+FE0E (text-style variation selector) to emoji-capable symbols like ↔ in its HTML output. The resulting ↔+FE0E cluster fails font shaping in EVERY font (including Apple Symbols, even inside the wrap span) and falls to .LastResort. Fix: strip ︎ from the generated HTML in step 4 (the same Python pass that injects CSS): h = h.replace('︎', ''). Leave ️ (emoji-style selector) alone — Apple Color Emoji handles those clusters.
c) Scale image references:
 or <img src="...">, leave the markdown as-is — image sizing is handled by CSS in step 3.Write the pre-processed markdown to a temp file (e.g., /tmp/md-to-pdf-<hash>.md).
pandoc --from markdown+hard_line_breaks+emoji \
--to html5 \
--standalone \
--metadata title="" \
-o /tmp/md-to-pdf-<hash>.html \
/tmp/md-to-pdf-<hash>.md
Key: hard_line_breaks makes every newline a <br>, which is the core line-break-preservation feature.
After pandoc generates the HTML, do both of these in one Python pass:
a) Strip text-style variation selectors (U+FE0E) that pandoc's +emoji extension appends to emoji-capable symbols like ↔ (see the gotcha in step 2b — the ↔+FE0E cluster fails shaping in every font and falls to .LastResort):
h = h.replace('︎', '') # strip VS15; leave ️ (emoji-style) alone
b) Inject this CSS into the <head> (before </head>):
@page {
size: A4;
margin: 2cm 2.5cm;
}
body {
/* Latin first → CJK fallback → symbol fallback. weasyprint resolves
per-glyph: English uses Helvetica/Arial (universally printable), CJK
falls through to Hiragino/PingFang. Do NOT put CJK fonts first — Latin
glyphs would get embedded as CID/Identity-H subsets and many printers /
Adobe Reader (Windows) render those as blank pages.
"Apple Symbols" + "Arial Unicode MS" at the end catch symbols the
earlier fonts lack (e.g. ↔ U+2194: Helvetica has no arrows, and the
GB-charset CJK fonts cover ←↑→↓ but NOT ↔) — without them weasyprint
falls to .LastResort, which renders as a boxed "?". */
font-family: -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, "Hiragino Sans GB", "PingFang SC", "Heiti SC", "Microsoft YaHei", "Apple Symbols", "Arial Unicode MS", sans-serif;
font-size: 11pt;
line-height: 1.7;
color: #1a1a1a;
}
img {
max-width: IMG_WIDTH%;
height: auto;
display: block;
margin: 0.5em auto;
}
table {
border-collapse: collapse;
width: 100%;
font-size: 10pt;
margin: 1em 0;
}
tr {
page-break-inside: avoid;
break-inside: avoid;
}
th, td {
border: 1px solid #999;
padding: 4px 8px;
text-align: left;
vertical-align: top;
}
th {
background: #f0f0f0;
font-weight: bold;
}
h1, h2, h3, h4 {
page-break-after: avoid;
margin-top: 1.5em;
}
h1 { font-size: 18pt; border-bottom: 2px solid #333; padding-bottom: 4px; }
h2 { font-size: 15pt; border-bottom: 1px solid #ccc; padding-bottom: 3px; }
h3 { font-size: 13pt; }
blockquote {
border-left: 3px solid #999;
margin-left: 0;
padding: 0.3em 1em;
color: #555;
background: #fafafa;
}
code {
font-family: "SF Mono", "Menlo", "Hiragino Sans GB", "Heiti SC", "PingFang SC", "Apple Symbols", "Arial Unicode MS", monospace;
font-size: 9pt;
background: #f5f5f5;
padding: 1px 4px;
border-radius: 2px;
}
pre {
background: #f5f5f5;
padding: 0.8em;
overflow-x: auto;
font-size: 9pt;
border-radius: 4px;
}
pre code {
background: none;
padding: 0;
}
Replace IMG_WIDTH with the --img-width value (default 60).
c) Append --extra-css, if given: after the default CSS block above, read that file's content and append it verbatim inside the same <style> block (after the defaults, so cascade order lets it extend/override). Do this in the same Python pass as (a) the VS15-strip and (b) the CSS-injection above — do not add a second pass or a separate <style> block.
weasyprint /tmp/md-to-pdf-<hash>.html "<output-path>"
Set the working directory to the markdown file's parent directory so relative image paths resolve correctly.
.md and .html files.Run pdffonts <output.pdf> and check two things:
Primary font is Latin: confirm the primary embedded font is Helvetica / Helvetica-Neue / Arial — NOT Hiragino-Sans-GB or another CJK font. If the primary is CJK, the PDF will print blank on Adobe Reader (Windows) and many office printers even though it looks fine in macOS Preview. This is the most common reason a generated PDF "loses all characters when printed."
No .LastResort font: if pdffonts lists a .LastResort entry, some character was not resolvable by the font stack and will render as a boxed "?" glyph. Find the culprit by scanning the source .md for uncommon symbols, e.g.:
import unicodedata
for ch in sorted(set(open('input.md', encoding='utf-8').read())):
o = ord(ch)
if o < 128 or 0x4E00 <= o <= 0x9FFF or 0x3000 <= o <= 0x303F or 0xFF00 <= o <= 0xFFEF:
continue
print(f'U+{o:04X} {ch!r} {unicodedata.name(ch, "?")}')
Then fix by adding the char to the step-2b wrap list (NOT by appending a font to the CSS stack — .LastResort outranks late-stack fonts in fontconfig's per-glyph sort, so that doesn't work on macOS) and confirm the step-4a VS15 strip ran. Regenerate and re-run pdffonts until .LastResort is gone, then visually spot-check the page containing the char (render with pdftoppm -png and Read the image).
What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub synx-data-labs/ccxp-skills --plugin ccxp-skills57 skills in this plugin
/1password-env-setupUse when the user explicitly asks to bootstrap or refresh a repo's 1Password-backed .env — installs the refresh-env helper, generates a hash-checking .envrc, and materializes .env from .env.tpl via op inject/address-prUse when the user explicitly asks to address, verify, or merge a specific open PR (CI, Claude Code review, test plan, tiered merge)/agent-pairingUse when the user explicitly asks to toggle the ccxp-agent main-session agent on/off for this Claude Code profile or check its status/agents-sdkBuild AI agents on Cloudflare Workers using the Agents SDK. Load when creating stateful agents, durable workflows, real-time WebSocket apps, scheduled tasks, MCP servers, chat applications, voice agents, or browser automation. Covers Agent class, state management, callable RPC, Workflows, durable execution, queues, retries, observability, and React hooks. Biases towards retrieval from Cloudflare docs over pre-trained knowledge./autopilotUse when the user explicitly asks to turn the unattended background /drive loop on or off, pause or resume it, or check its status — "/autopilot on", "/autopilot off", "/autopilot pause", "/autopilot resume", "/autopilot status", "/autopilot config"/bottomUse when the user explicitly asks to move a task (or several) to the back of the dev/TODO priority queue