Render any .md into VitePress-style self-contained HTML, then with the help of html-cut take a screenshot as a high-definition PNG, for convenient viewing on a phone or sending via chat tools.
Startup
python3 scripts/md_to_png.py path/to/skill.md /tmp/out.png
On success, stdout outputs only the absolute PNG path (consistent with the html-cut output convention).
Parameters
| Parameter | Description |
|---|---|
md |
Markdown file path |
output |
PNG output path, can be omitted, defaults to writing to the system temporary directory |
--title |
HTML title, defaults to the first # heading of the md |
--width |
Viewport width, default 740(mobile reading friendly) |
--height |
Viewport height, default 900 |
--scale |
Device pixel ratio, default 2 |
--color-scheme |
light or dark, default light |
--wait MS |
Extra wait in milliseconds after loading, default 500 |
Common examples
# 默认亮色、740 宽,适合手机阅读
python3 scripts/md_to_png.py SKILL.md /tmp/skill.png
# 宽屏深色
python3 scripts/md_to_png.py README.md /tmp/readme.png \
--width 1280 --scale 3 --color-scheme dark
Workflow
- Confirm the input md file exists
- The script automatically locates the same repository's
skills/html-cut/scripts/capture.pyto take the screenshot - After execution, check the absolute PNG path in stdout, and if necessary send it to the user via tools such as lan-chat
Rendering scope
Minimal Markdown conversion, covering: YAML frontmatter (automatically removed), headings #, paragraphs, unordered lists -, fenced code blocks, GFM tables, inline code / **bold** / [link](url). Does not render advanced syntax such as images, blockquotes, or ordered lists.
Dependencies
- html-cut: Screenshots are done by the
html-cutskill'scapture.py, and require Playwright and Chromium to be installed first - If not installed, it will error with a non-zero exit code; handle it according to the troubleshooting in
html-cutSKILL.md
Notes
This skill's screenshots depend on the same repository's html-cut skill
| Symptom | Handling |
|---|---|
找不到 html-cut 脚本 |
npx skills add https://github.com/gitByEOS/open-part-skills --skill html-cut |
Chromium 找不到 / Executable doesn't exist |
python3 -m playwright install chromium |
Agent notes
- When the user does not provide an output path, output to the temporary directory to avoid overwriting existing project files
- After the screenshot is complete, report the absolute PNG path; do not paste the binary image content into the reply
- If the screenshot needs to be sent to the user, you can combine it with
lan-chat's file-sending capability