md2we-render-markdown
Use MD2WE's online /api/convert endpoint to render Markdown into styled HTML.
When To Use
Use this skill when the user wants to:
- Convert a Markdown file into WeChat-compatible HTML
- Compare MD2WE theme variants
- Render with a specific code theme, font size, or background
- Save rendered HTML to disk for later publishing
Service Check
Default base URL:
export MD2WE_BASE_URL="${MD2WE_BASE_URL:-https://md2we.com}"
Before rendering, verify the service:
curl -sS "${MD2WE_BASE_URL}/api/health"
If the service is unavailable and the current repo is MD2WE, start it from the repo root:
python3 app.py
Then point the base URL to the local service and retry /api/health:
export MD2WE_BASE_URL="http://127.0.0.1:5566"
curl -sS "${MD2WE_BASE_URL}/api/health"
API Call Pattern
Basic render:
curl -sS "${MD2WE_BASE_URL}/api/convert" \
-H "Content-Type: application/json" \
-d @<(jq -Rs '{
markdown: .,
theme: "default",
code_theme: "github",
font_size: "medium",
background: "warm"
}' article.md)
Choose render options:
curl -sS "${MD2WE_BASE_URL}/api/convert" \
-H "Content-Type: application/json" \
-d @<(jq -Rs '{
markdown: .,
theme: "tech",
code_theme: "monokai",
font_size: "large",
background: "warm"
}' article.md)
Render from stdin:
cat article.md | jq -Rs '{
markdown: .,
theme: "default",
code_theme: "github",
font_size: "medium",
background: "warm"
}' | curl -sS "${MD2WE_BASE_URL}/api/convert" \
-H "Content-Type: application/json" \
-d @-
Write the returned html field to a file:
response=$(curl -sS "${MD2WE_BASE_URL}/api/convert" \
-H "Content-Type: application/json" \
-d @<(jq -Rs '{
markdown: .,
theme: "default",
code_theme: "github",
font_size: "medium",
background: "warm"
}' article.md))
echo "$response" | jq -e '.success == true' >/dev/null || {
echo "$response" | jq .
exit 1
}
echo "$response" | jq -r '.html' > article.html
Supported Values
theme: default|sport|chinese|cyberpunk|ocean|forest|sunset|lavender|coffee|minimalist|tech|retro|government|finance
code_theme: github|monokai|dracula|atom-one-dark|atom-one-light|vs|xcode|stackoverflow-light
font_size: small|medium|large
background: warm|grid|none
Result Handling
- Read the
htmlfield from the JSON response. - If the user asked for a file, write only the
htmlfield to disk. - If the user asked for a quick preview only, inspect the JSON response and summarize the chosen settings.
- If rendering fails, surface the server error directly. Do not guess at broken HTML.