When inserting diagrams into a Markdown document, always follow the rules below.
Before doing anything, check that dependencies are installed:
which mddoc && which d2
If mddoc is not installed:
npm install -g mddoc-cli
If d2 is not installed:
brew install d2winget install terrastruct.d2Make sure both are available before continuing.
.mddoc/ directory (alongside the Markdown file)auth-flow, module-overview) — no spaces or numbers.mddoc/ if it does not exist1. Write the source file → .mddoc/ in markmap markdown format:
# Root node
## Branch one
- Leaf node
- Leaf node
## Branch two
- Leaf node
- Child leaf
2. Generate PNG:
mddoc mindmap .mddoc/<name>.mmd
3. Embed in Markdown:

*Source: [<name>.mmd](.mddoc/<name>.mmd)*
1. Write the source file → .mddoc/ in D2 language:
direction: right
client: Client {shape: rectangle}
gateway: API Gateway {shape: rectangle}
db: Database {shape: cylinder}
client -> gateway -> db
2. Generate PNG:
mddoc arch .mddoc/<name>.d2
3. Embed in Markdown:

*Source: [<name>.d2](.mddoc/<name>.d2)*
mddoc build
Issues and suggestions → https://github.com/drunkpig/md-of-programer/issues
共 1 个版本