How dawnsws/md2png works
md2png is a command-line Markdown-to-PNG renderer. Its main workflow accepts a Markdown file or clipboard text, converts Markdown (including tables, images, code, and math) to Typst markup, compiles and rasterizes pages, then writes uniquely named PNG files. The internal rendering layer supplies fonts and safely resolves document-relative resources. The README is empty, so capabilities and wiring here reflect the sampled source; Windows clipboard support is conditional.
Main entry points: render.rs Compile and export · main.rs CLI workflow · markdown.rs Markdown conversion · input.rs Input loading
Components 17
Input
- CLI workflow
src/main.rs - Input loading
src/input.rs
Conversion
- Markdown conversion
src/markdown.rs - Typst preamble
src/preamble.typ - Markdown parser
- Math converter
Rendering
- Compile and export
src/render.rs - Typst world
src/world.rs - Typst compiler
- Page rasterizer
Output
- PNG file writer
src/output.rs
Other components
- User
- Markdown file
- System clipboard
- Local filesystem
- Typst font assets
- PNG files
Connections 22
- User → CLI workflow: invokes
- Markdown file → Input loading: reads
- System clipboard → Input loading: provides text
- Local filesystem → Input loading: reads file
- CLI workflow → Input loading: parses and loads
- Input loading → CLI workflow: returns content
- CLI workflow → Markdown conversion: converts content
- Markdown conversion → Markdown parser: parses Markdown
- Markdown conversion → Math converter: converts formulas
- Typst preamble → Markdown conversion: included in markup
- Markdown conversion → Compile and export: returns markup
- CLI workflow → Compile and export: renders markup
- Compile and export → Typst world: creates resource world
- Compile and export → Typst compiler: compiles document
- Typst compiler → Typst world: requests sources and files
- Typst world → Typst font assets: loads font data
- Typst world → Local filesystem: reads local resources
- Compile and export → Page rasterizer: rasterizes pages
- Compile and export → PNG file writer: saves encoded PNG
- PNG file writer → Local filesystem: creates unique files
- Local filesystem → PNG files: stores
- Compile and export → CLI workflow: returns output paths