22
33Converts dynamic Mermaid diagrams to static SVG images for better performance and accessibility.
44
5+ ## Prerequisites
6+
7+ - Python 3.7+
8+ - Node.js 14+
9+ - Jekyll (for local testing)
10+
511## Quick Start
612
713``` bash
814bash scripts/setup.sh
915```
1016
17+ ## Manual Setup
18+
19+ If you can't run the setup script:
20+
21+ 1 . Install dependencies:
22+ ``` bash
23+ pip install -r requirements.txt
24+ npm install -g @mermaid-js/mermaid-cli
25+ ```
26+
27+ 2 . On Linux, install Chrome dependencies:
28+ ``` bash
29+ sudo apt install -y libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 libxfixes3 libxrandr2 libgbm1 libasound2
30+ ```
31+
32+ 3 . Generate fonts:
33+ ``` bash
34+ python3 scripts/generate_embedded_fonts.py
35+ ```
36+
1137## How It Works
1238
13- 1 . ** Add flag to post front matter:**
14- ``` yaml
15- ---
16- mermaid : true
17- use_static_image : true # ← Add this line
18- ---
19- ```
39+ 1 . Add flag to post front matter:
40+
41+ ``` yaml
42+ ---
43+ mermaid : true
44+ use_static_image : true # ← Add this line
45+ ---
46+ ```
2047
21- 2 . ** Generate static images:**
22- ``` bash
23- python3 scripts/generate_images_only.py " 053.md"
24- ```
48+ 2 . Generate static images:
49+
50+ ``` bash
51+ python3 scripts/generate_images_only.py " 053.md"
52+ ```
2553
26- 3 . ** Test locally:**
27- ``` bash
28- bundle exec jekyll serve
29- ```
54+ 3 . Test locally:
55+
56+ ``` bash
57+ bundle exec jekyll serve
58+ ```
3059
3160## Usage
3261
@@ -37,24 +66,55 @@ python3 scripts/generate_images_only.py
3766# Generate for specific posts
3867python3 scripts/generate_images_only.py " 053.md"
3968
40- # Force regeneration of all cards
69+ # Force regeneration of all images
4170python3 scripts/generate_images_only.py --force
4271
43- # Force regeneration of a specic card
72+ # Force regeneration of specific post
4473python3 scripts/generate_images_only.py " 053.md" --force
4574
4675# Verbose output
4776python3 scripts/generate_images_only.py --verbose
4877```
4978
50- ## Setup Requirements
79+ ## Project Structure
80+
81+ ```
82+ gitfichas/
83+ ├── _posts/ # Markdown posts with mermaid diagrams
84+ ├── assets/img/mermaid/ # Generated static SVG files
85+ ├── scripts/ # Setup and generation scripts
86+ └── requirements.txt # Python dependencies
87+ ```
88+
89+ ## Example
90+
91+ ** Input** (` _posts/2024-01-01-example.md ` ):
92+ ```` markdown
93+ ---
94+ title: "My Post"
95+ mermaid: true
96+ use_static_image: true
97+ ---
98+
99+ ```mermaid
100+ graph TD
101+ A[Start] --> B[End]
102+ ```
103+ ````
104+
105+ ** Output** : Creates ` assets/img/mermaid/2024-01-01-example-0.svg `
51106
52- The setup script handles everything automatically, but manual setup requires:
107+ ## Maintenance
53108
54- - Node.js and npm
55- - Python dependencies: ` pip install -r requirements.txt `
56- - Mermaid CLI: ` npm install -g @mermaid-js/mermaid-cli `
57- - System libraries for headless Chrome (auto-installed by setup script)
109+ Remove all generated images:
110+ ``` bash
111+ rm -rf assets/img/mermaid/* .svg
112+ ```
113+
114+ Regenerate everything:
115+ ``` bash
116+ python3 scripts/generate_images_only.py --force
117+ ```
58118
59119## Troubleshooting
60120
@@ -66,4 +126,6 @@ The setup script handles everything automatically, but manual setup requires:
66126
67127** Debug mode:** Use ` --verbose ` flag for detailed output
68128
69- MIT License - Feel free to adapt for your own Jekyll sites!
129+ ## License
130+
131+ MIT License - Feel free to adapt for your own Jekyll sites!
0 commit comments