Generate a production-grade branded PDF from a markdown source file using the pdf-factory pipeline.
$ARGUMENTS
Parse arguments: <markdown-file> [--brand <name>] [--output <path>]
<markdown-file>-- path to the source markdown file (required)--brand <name>-- brand kit name:bluewaves,wave-artisans, ordecathlon(default:bluewaves)--output <path>-- output PDF path (default: same directory as input,.pdfextension)
Steps
-
Parse arguments from
$ARGUMENTS. Extract markdown file path, brand name, and output path. -
Verify dependencies are installed:
python3 -c "import xhtml2pdf, reportlab, pypdf, markdown, lxml, PIL, html5lib, cssselect2" 2>/dev/nullIf this fails, run the install-docs-deps skill first.
-
Resolve brand kit at
${SKILL_ROOT}/../brand-<name>/. Verify the directory exists and containsassets/manifest.json. -
Read the markdown file and extract frontmatter metadata (title, subtitle, author, date). Convert markdown to HTML:
python3 -c " import markdown, json, sys, re with open('<markdown-file>') as f: source = f.read() # Extract YAML frontmatter fm_match = re.match(r'^---\n(.*?)\n---\n', source, re.DOTALL) meta = {} if fm_match: for line in fm_match.group(1).splitlines(): if ':' in line: key, val = line.split(':', 1) meta[key.strip()] = val.strip() source = source[fm_match.end():] # Convert to HTML html = markdown.markdown(source, extensions=['tables', 'fenced_code', 'codehilite', 'toc', 'meta', 'attr_list']) with open('<output-dir>/content.html', 'w') as f: f.write(html) with open('<output-dir>/metadata.json', 'w') as f: json.dump(meta, f, indent=2) print('Parsed markdown and extracted metadata.') " -
Render content pages:
python3 ${SKILL_ROOT}/../pdf-factory/scripts/render.py \ --brand ${SKILL_ROOT}/../brand-<name> \ --input <output-dir>/content.html \ --output <output-dir>/content-pages.pdf -
Compose final document:
python3 ${SKILL_ROOT}/../pdf-factory/scripts/compose.py \ --brand ${SKILL_ROOT}/../brand-<name> \ --content <output-dir>/content-pages.pdf \ --metadata <output-dir>/metadata.json \ --output <output-path> -
Validate output:
python3 ${SKILL_ROOT}/../pdf-factory/scripts/validate_output.py \ <output-path> \ --brand ${SKILL_ROOT}/../brand-<name> -
Clean up temporary files (content.html, content-pages.pdf, metadata.json).
-
Report results -- output path, page count, file size, and validation status.