-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
143 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
name: Test D2 Quarto Extension | ||
|
||
on: [push] | ||
|
||
jobs: | ||
test_extension: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Set up Quarto | ||
uses: quarto-dev/quarto-actions/setup@v2 | ||
|
||
- name: Install D2 | ||
run: curl -fsSL https://d2lang.com/install.sh | sh -s -- | ||
|
||
- name: Render Quarto document | ||
run: | | ||
cp -r _extensions tests | ||
for file in $(find tests -name "*.qmd"); do | ||
quarto render $file | ||
done | ||
- name: Upload PDF artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: rendered-output | ||
path: tests |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
--- | ||
title: D2 Extension For Quarto | ||
format: gfm | ||
filters: | ||
- d2 | ||
d2: | ||
layout: "elk" | ||
--- | ||
|
||
This [Quarto](https://quarto.org) extension allows you to render [D2](https://d2lang.com) diagrams directly within your markdown documents. | ||
|
||
Main features: | ||
|
||
- Render [D2](https://d2lang.com) diagrams directly within your [Quarto](https://quarto.org) markdown documents. | ||
- Control the appearance and layout of your diagrams using global settings or code block attributes. | ||
- Tune the width and height of the resulting figures using the "width" and "height" arguments. | ||
|
||
This extension was inspired by [`ram02z/d2-filter`](https://github.com/ram02z/d2-filter). | ||
|
||
## Installation | ||
|
||
### Prerequisites | ||
|
||
Ensure that you have [D2](https://d2lang.com/tour/install) installed on your system. | ||
|
||
### Install | ||
|
||
Run the following command to add this extension to your current project: | ||
|
||
``` bash | ||
quarto add data-intuitive/quarto-d2 | ||
``` | ||
|
||
This will install the extension under the `_extensions` subdirectory. | ||
If you're using version control, you will want to check in this directory. | ||
|
||
|
||
|
||
## Example | ||
|
||
|
||
```{.d2 width="50%" echo="true"} | ||
logs: { | ||
shape: page | ||
style.multiple: true | ||
} | ||
user: User {shape: person} | ||
network: Network { | ||
tower: Cell Tower { | ||
satellites: { | ||
shape: stored_data | ||
style.multiple: true | ||
} | ||
satellites -> transmitter | ||
satellites -> transmitter | ||
satellites -> transmitter | ||
transmitter | ||
} | ||
processor: Data Processor { | ||
storage: Storage { | ||
shape: cylinder | ||
style.multiple: true | ||
} | ||
} | ||
portal: Online Portal { | ||
UI | ||
} | ||
tower.transmitter -> processor: phone logs | ||
} | ||
server: API Server | ||
user -> network.tower: Make call | ||
network.processor -> server | ||
network.processor -> server | ||
network.processor -> server | ||
server -> logs | ||
server -> logs | ||
server -> logs: persist | ||
server -> network.portal.UI: display | ||
user -> network.portal.UI: access { | ||
style.stroke-dash: 3 | ||
} | ||
``` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
--- | ||
title: "D2 Example" | ||
format: html | ||
filters: | ||
- d2 | ||
d2: | ||
format: svg | ||
embed_mode: raw | ||
--- | ||
|
||
```{.d2 width="40%"} | ||
x { | ||
link: "https://quarto.org" | ||
} | ||
y { | ||
tooltip: "This is a tooltip" | ||
} | ||
x -> y -> z | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
--- | ||
title: "D2 Example" | ||
filters: | ||
- d2 | ||
--- | ||
|
||
```{.d2} | ||
x -> y | ||
``` |