with one click
analyze-to-pdf
// Convert experiment analysis reports (report.md) to PDF using pandoc. Use after analyze-experiment to create shareable PDF reports.
// Convert experiment analysis reports (report.md) to PDF using pandoc. Use after analyze-experiment to create shareable PDF reports.
[HINT] Download the complete skill directory including SKILL.md and all related files
| name | analyze-to-pdf |
| description | Convert experiment analysis reports (report.md) to PDF using pandoc. Use after analyze-experiment to create shareable PDF reports. |
Convert a markdown file to PDF using pandoc. Designed for experiment analysis reports but works with any markdown file.
Verify tools are available before proceeding:
which pandoc
If missing, stop and report:
pandoc is not installed. Install it with your package manager (e.g., apt install pandoc, dnf install pandoc).
which xelatex # preferred — better Unicode support
which pdflatex # fallback
If neither is found, stop and report:
No PDF engine found. pandoc needs a LaTeX installation to produce PDFs.
Install texlive (e.g., apt install texlive-xetex or dnf install texlive-xetex).
Record which engine is available for the conversion step.
If user provides a path argument: Use that path directly.
If no argument provided:
experiment_summary.yamlanalysis/report.mdValidate the file exists before proceeding.
Reports may contain HTML <details> blocks (collapsible sections) that LaTeX cannot render. Expand them before conversion:
from pathlib import Path
from cruijff_kit.tools.inspect.report_generator import expand_details_for_pdf
md_path = Path("{full_path_to_md}")
text = md_path.read_text()
expanded = expand_details_for_pdf(text)
# Write to a temp file in the same directory (so relative image paths still work)
tmp_path = md_path.with_suffix(".tmp.md")
tmp_path.write_text(expanded)
This converts <summary> text to bold labels and <pre><code> blocks to fenced code blocks. If the markdown has no <details> blocks, the text passes through unchanged.
Critical: Change to the markdown file's parent directory before running pandoc. This ensures relative image paths (e.g., ) resolve correctly.
cd {parent_directory}
pandoc {tmp_filename} -o {stem}.pdf --pdf-engine={engine} \
--from markdown-implicit_figures \
-V geometry:margin=1in
Why these flags matter:
--from markdown-implicit_figures — disables pandoc's automatic wrapping of images in LaTeX \begin{figure} float environments. Without this, LaTeX treats every image as a float and reorders them past surrounding text onto later pages. With this flag, images are inline \includegraphics calls that appear exactly where they are in the markdown, just like text. The tradeoff is no Figure N: captions, but report images already have ### headings so captions are redundant.geometry:margin=1in — maximizes page real estate for figuresWhere {stem} is the original filename without the .md extension (e.g., report.md → report.pdf).
After conversion, clean up the temp file:
tmp_path.unlink()
On success:
PDF created: {full_path_to_pdf} ({file_size})
On failure: Show the pandoc error output. Common issues:
tlmgr install {package} or a fuller texlive installcd into the file's directory is what makes relative image paths work. Do not skip this.