Use this case when a user gives a Markdown report that is mostly Chinese prose + tables and asks for a more visual PDF, especially when the acceptance criteria require:
This is a stricter sibling of templates/data-viz-report/: the normal data-viz-report skeleton is chart-rich and may use Chart.js; this case is for evaluation-style requirements where static chart artifacts and source-structure fidelity matter more than interactive-looking design.
Source: Apple_M系列芯片AI部署全面分析报告.md.
Initial ask:
这个md以文本和表格为主,我需要你生成一份数据可视化表现更好的图文详情的pdf报告给我,更方便我查看
Strict acceptance criteria added after first attempt:
Do not repeat the first-attempt pattern when the strict criteria above are present:
Recovery was to rebuild from the original Markdown as the canonical structure, then insert static charts after the relevant source tables.
bash <SKILL>/scripts/make.sh check
python3 - <<'PY'
import importlib.util
for m in ['matplotlib', 'markdown_it', 'bs4']:
print(m, bool(importlib.util.find_spec(m)))
PY
Expected evidence:
make.sh check reports OK for Python, Node, Playwright, pdfinfo.matplotlib, markdown_it, and bs4 are available.If matplotlib is missing, install it in the active Python environment or use SVG generated by deterministic Python code. Do not fall back to Chart.js when the acceptance criteria bans runtime chart libraries.
Read the Markdown source and identify:
## / ### headings;For this case:
表1.1:Apple M系列芯片关键硬件规格对比 → static chart 图1.1.表1.2:Apple M系列芯片GeekBench 6性能得分 → static chart 图1.2.图1.1:Apple M-Max系列芯片性能代际对比 → optional static chart 图1.3 using original table 1.2 values indexed to M1 Max = 100.Do not infer or “clean up” data silently. Keep values such as 未披露 and 300/400 GB/s visibly faithful to the source. If a value cannot be plotted, annotate it rather than inventing a number.
Use Markdown rendering for prose/table fidelity, then manipulate the HTML fragment:
from markdown_it import MarkdownIt
from bs4 import BeautifulSoup, NavigableString
md = MarkdownIt('commonmark', {'html': False, 'breaks': False}) \
.enable('table') \
.enable('strikethrough')
body_html = md.render(md_text)
soup = BeautifulSoup(body_html, 'html.parser')
Rules:
html=False unless the source HTML is trusted and required.Remove leftover Markdown emphasis markers caused by malformed source, e.g. orphan ** around quoted phrases:
for node in soup.find_all(string=True):
if isinstance(node, NavigableString) and '**' in node:
node.replace_with(node.replace('**', ''))
No translation was needed in this run. For Chinese technical Markdown, preserve source terminology unless the user asks for localization changes.
Keep these terms stable:
| Source term | Output rule |
|---|---|
| Apple M系列 | keep as Apple M系列 |
| Qwen 32B / Qwen3-32B | keep model name unchanged |
| INT4 / INT8 / BF16 / Q8_0 / Q4_K_M | keep exact technical tokens |
| 统一内存架构(UMA) | keep Chinese + acronym |
| 神经网络引擎(NE) / ANE | do not merge unless source does |
| RTX 5090 / TensorRT-LLM / CUDA | keep exact names |
| tokens/s / Time To First Token (TTFT) | keep source bilingual form when present |
If a later task involves translation, add a short glossary before rendering and validate that model names, chip names, units, and benchmark labels are untouched.
Use Matplotlib or deterministic SVG/PNG generation. Store only editable source HTML and code/pseudocode in the case; do not store generated PDFs.
Recommended chart shape:
未披露, show an annotation instead of a fake zero.300/400 GB/s, draw a range marker or label as 300/400.Recommended chart shape:
For the original placeholder “M-Max系列芯片性能代际对比”, generate a static line chart from table 1.2 values:
M1 Max, M2 Max, M3 Max, M4 Max;Use a restrained print-academic shell around the rendered Markdown:
16mm 14mm 17mm 14mm worked here).assets/.<figcaption> text, e.g. 图1.1:..., not CSS counters.Minimal CSS pattern:
@page { size: A4 portrait; margin: 16mm 14mm 17mm 14mm; }
* { box-sizing: border-box; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
html, body {
margin: 0; padding: 0; background: #fff; color: #172033;
font-family: "PingFang SC", "Songti SC", "Noto Sans CJK SC", "Microsoft YaHei", Arial, sans-serif;
font-size: 10.2pt; line-height: 1.62;
}
h1 { font-size: 24pt; text-align: center; margin: 16mm 0 9mm; }
h2 { font-size: 16pt; margin: 11mm 0 4mm; border-bottom: 1.4pt solid #2f8f83; }
h3 { font-size: 12.4pt; margin: 7mm 0 3mm; }
.data-table { width: 100%; border-collapse: collapse; font-size: 7.45pt; table-layout: fixed; }
.data-table th { background: #eef6f5; border: .55pt solid #b7c9c7; }
.data-table td { border: .45pt solid #d6dee8; word-break: break-word; }
.figure-block { margin: 5mm 0 7mm; page-break-inside: avoid; text-align: center; }
.figure-block img { max-width: 100%; max-height: 205mm; border: .5pt solid #d8e0ea; }
.figure-block figcaption { margin-top: 2mm; font-size: 8.6pt; color: #526173; }
bash <SKILL>/scripts/make.sh render \
--in <TMP>/source.html \
--out <OUTPUT_PATH> \
--format A4 \
--wait 15000
Even though static images do not need Chart.js settle time, keep --wait 15000 when local fonts or large images are involved; it is cheap and avoids racey print snapshots.
Run all of these; do not suppress stderr.
pdfinfo <OUTPUT_PATH>
pdfimages -list <OUTPUT_PATH>
pdftotext -layout <OUTPUT_PATH> -
Expected evidence from the successful run:
pdfinfo:
Pages: 11Page size: 595.92 x 842.88 pts (A4)JavaScript: nopdfimages -list:
pdftotext -layout:
表1.1, 图1.1, 表1.2, 图1.2;引言, 第一部分, 第二部分, 第三部分, 结论与最终建议, 附录:参考资料;** emphasis markers.For quick checks:
pdftotext -layout <OUTPUT_PATH> - | grep -E '表1\.1|图1\.1|表1\.2|图1\.2|结论与最终建议|附录'
pdftotext -layout <OUTPUT_PATH> - | grep '\*\*' && echo 'FAIL: raw markdown markers remain'
| Pitfall | Symptom | Recovery |
|---|---|---|
| Rewriting into an executive brief | Structure/order no longer matches source | Render the Markdown first, then insert figures; do not re-outline. |
| Runtime chart library used despite static requirement | HTML contains Chart.js/ECharts/D3/Plotly script | Regenerate charts with Matplotlib/SVG and embed PNG/SVG files. |
| Raw Markdown markers remain | pdftotext shows ** or code fences |
Use markdown-it; remove orphan markers only after render; inspect text output. |
| Table too wide | columns wrap awkwardly or overflow | Use table-layout: fixed, small table font, word-break: break-word; keep A4 portrait unless user accepts landscape. |
| Chart data “normalized” without disclosure | acceptance says data was changed | Keep source tables intact; if deriving an index chart, label it explicitly as derived. |
未披露 plotted as 0 |
chart implies a false value | Annotate as 未披露; do not include it in numeric axis calculations. |
| Decorative generation note unwanted | first page begins with process metadata | Remove .report-meta / .toc-note before final render. |
Verification only uses pdftotext |
chart-less PDF passes text check | Always run pdfimages -list; images are the evidence for static chart embedding. |
pdf; match P3, but if criteria mention static charts / no runtime chart libs / preserve Markdown hierarchy, use this case instead of the default Chart.js data-viz skeleton.markdown-it-py; keep original order.<figure> blocks immediately after the corresponding source tables.make.sh render --format A4 --wait 15000.Editable source HTML from the successful run is stored at:
templates/data-viz-report/cases/apple-m-ai-static-academic/source.htmlIt intentionally does not include the generated PDF. Recreate the PDF with:
bash <SKILL>/scripts/make.sh render \
--in <SKILL>/templates/data-viz-report/cases/apple-m-ai-static-academic/source.html \
--out /tmp/apple-m-ai-static-academic.pdf \
--format A4 \
--wait 15000
Note: the source HTML references assets/fig_*.png relative to its case directory. If those assets are not present, regenerate them from the source table data using the Matplotlib strategy above, or replace with fresh static figures before rendering.