landmaj / mkdocs-d2-plugin

A plugin for embedding D2 diagrams in MkDocs.
https://landmaj.github.io/mkdocs-d2-plugin/
MIT License
25 stars 4 forks source link

Add support for --target option #6

Closed Karreg closed 11 months ago

Karreg commented 11 months ago

Hi,

This PR adds support for the --target option.

As this option does not come with environment variable equivalent (which makes sense) I have switched the option system in the plugin to a command line option system.

The --target option is always set, default is ''. The idea is that multi-layer diagram included in mkdocs won't work without this option, and generating all files does not make much sense. It could be a future improvement to handle it though.

Here is a code to test this feature.

in test.d2:

A -> B

scenarios: {
    alternate: {
        B -> A
    }
}

in test.md:

# multilayer test

![d2](devcontainer/test.d2)

![d2](devcontainer/test.d2){target="alternate"}

The result is the following:

image

Fixes #4

landmaj commented 11 months ago

Hi,

thanks for your PR. I have a few ideas for improvements but I can't push commits to your branch, so I will merge it and push changes directly to my repo.