diff --git a/CHANGELOG.md b/CHANGELOG.md
index 6f8a90e..cd21b91 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,10 @@
+# quarto-d2 1.2.0
+
+## NEW FUNCTIONALITY
+
+- Allow using the filter as a simple pandoc filter. This allows using the filter with other
+ document formats such as Rmarkdown.
+
# quarto-d2 1.1.0
## NEW FUNCTIONALITY
diff --git a/README.md b/README.md
index b0a79e4..7bfa397 100644
--- a/README.md
+++ b/README.md
@@ -16,24 +16,6 @@ Main features:
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
@@ -89,11 +71,39 @@ user -> network.portal.UI: access {
+## Prerequisites
+
+Ensure that you have [D2](https://d2lang.com/tour/install) installed on
+your system.
+
## Usage
-To use the d2 filter, add the d2 filter to your quarto document. Next,
-add the `.d2` class to any code blocks containing D2 diagram code. Here
-is a basic example:
+The filter allows rendering D2 diagrams directly within your markdown
+documents.
+
+### Plain pandoc
+
+If you are using plain pandoc, you can use the `d2` filter by specifying
+it on the command line:
+
+``` bash
+pandoc --lua-filter d2.lua ...
+```
+
+### Quarto
+
+Install this filter as an extension with:
+
+``` 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.
+
+By adding d2 to the list of filters in the YAML headers, you can use the
+`.d2` code block to render D2 diagrams directly within your markdown
+documents.
```` markdown
---
@@ -107,11 +117,17 @@ x -> y
```
````
-With this setup, the `d2` filter will process any code blocks with the
-`.d2` class, applying the attributes you specify.
+### RMarkdown
+
+Use `pandoc_args` to add the `d2` filter.
-That’s it! Now you know how to use the `d2` filter to generate diagrams
-in your quarto documents.
+``` yaml
+---
+output:
+ html_document:
+ pandoc_args: ['--lua-filter=d2.lua']
+---
+```
## Attributes
@@ -223,3 +239,8 @@ y {
x -> y -> z
```
````
+
+## License
+
+This extension is distributed under the GPL-3 license, see file
+[`LICENSE`](LICENSE) for details.
diff --git a/README.qmd b/README.qmd
index 7d150c2..63fac81 100644
--- a/README.qmd
+++ b/README.qmd
@@ -17,24 +17,6 @@ Main features:
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
@@ -87,10 +69,37 @@ user -> network.portal.UI: access {
```
+## Prerequisites
+
+Ensure that you have [D2](https://d2lang.com/tour/install) installed on your system.
+
+
## Usage
-To use the d2 filter, add the d2 filter to your quarto document. Next, add the `.d2` class to any code blocks containing D2 diagram code. Here is a basic example:
+The filter allows rendering D2 diagrams directly within your markdown documents.
+
+### Plain pandoc
+If you are using plain pandoc, you can use the `d2` filter by specifying it on the command line:
+
+```bash
+pandoc --lua-filter d2.lua ...
+```
+
+### Quarto
+
+
+Install this filter as an extension with:
+
+``` 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.
+
+By adding d2 to the list of filters in the YAML headers, you can use the `.d2` code block to
+render D2 diagrams directly within your markdown documents.
````markdown
---
@@ -104,9 +113,17 @@ x -> y
```
````
-With this setup, the `d2` filter will process any code blocks with the `.d2` class, applying the attributes you specify.
+### RMarkdown
-That's it! Now you know how to use the `d2` filter to generate diagrams in your quarto documents.
+Use `pandoc_args` to add the `d2` filter.
+
+```yaml
+---
+output:
+ html_document:
+ pandoc_args: ['--lua-filter=d2.lua']
+---
+```
## Attributes
@@ -191,3 +208,7 @@ y {
x -> y -> z
```
````
+
+## License
+
+This extension is distributed under the GPL-3 license, see file [`LICENSE`](LICENSE) for details.
\ No newline at end of file
diff --git a/_extensions/d2/d2.lua b/_extensions/d2/d2.lua
index 3fd8815..4626bee 100644
--- a/_extensions/d2/d2.lua
+++ b/_extensions/d2/d2.lua
@@ -1,3 +1,6 @@
+-- The filter uses walk, which was added in Pandoc 2.17
+PANDOC_VERSION:must_be_at_least '2.17'
+
-- Enum for D2Theme
local D2Theme = {
NeutralDefault = 0,
@@ -196,6 +199,9 @@ local function render_graph(globalOptions)
print("Error: Unsupported format")
return nil
end
+ else
+ print("Error: Unsupported embed_mode")
+ return nil
end
end
end)
diff --git a/d2.lua b/d2.lua
new file mode 120000
index 0000000..8075e5e
--- /dev/null
+++ b/d2.lua
@@ -0,0 +1 @@
+_extensions/d2/d2.lua
\ No newline at end of file