Skip to content
This repository has been archived by the owner on Dec 7, 2024. It is now read-only.

Commit

Permalink
allow specifying code languages that get automatically promoted into …
Browse files Browse the repository at this point in the history
…kroki blocks
  • Loading branch information
damageboy committed Sep 20, 2022
1 parent 315ba93 commit 3dab18c
Show file tree
Hide file tree
Showing 7 changed files with 9,292 additions and 10 deletions.
51 changes: 51 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The include code plugin is normally used in the context of a site generator usin
1. __lang__: The image transformations is applied for all codeblocks with this language.
1. __imgRefDir__: The prefix that will be used for a generated image to create the link.
1. __imgDir__: The directory where the generated image files are stored.
1. __langAliases__: an array of markdown code languages that get treated as a kroki document ([See blow](#automatic-use-of-existing-language-tags))

### Docusaurus 2

Expand Down Expand Up @@ -62,6 +63,8 @@ The user can decide to put generated images under version control so that images

### Examples

#### Explicit kroki "language"

__Generate a mermaid image__

<pre>
Expand All @@ -85,6 +88,54 @@ graph TD
```
</pre>

#### Automatic use of existing language tags

In some cases, it would make a lot of sense to preserve the original language tag, for example `mermaid` documents are a first-class citizen in many markdown editors and is even explicitly supported inside popular code hosting services such as GitHub and GitLab.

In such cases, in would make sense to supply the optional `langAliases` option as part of the kroki plugin setup like so, to avoid rewriting the language tag for existing code-blocks that work well in other environments not related to remark/kroki:

```json
presets: [[
'@docusaurus/preset-classic',
{
docs: {
sidebarPath: require.resolve('./sidebars.js'),
remarkPlugins: [
[require('remark-kroki-plugin'), { i
krokiBase: 'https://kroki.io',
lang: "kroki",
langAliases: ["mermaid"],
imgRefDir: "../img/kroki",
imgDir: "static/img/kroki"
}]
],
}}
]]
```

This in turn allows for direct inclusing of mermaid blocks in a more straight-forward manner:

<pre>
```mermaid
graph TD
subgraph Shop X
Bx(Shop X) --> FX1((Fs X1)) --> Bx
Bx --> FX2((Fs X2)) --> Bx
end
subgraph Shop Y
By(Shop Y) --> FY1((Fs Y1)) --> By
By --> FY2((Fs Y2)) --> By
end
subgraph Shop Z
Bz(Shop Z) --> FZ1((Fs Z1)) --> Bz
Bz --> FZ2((Fs Z2)) --> Bz
end
A(Data Center) --> Bx --> A
A --> By --> A
A --> Bz --> A
```
</pre>

## Development

It might be good to allow the generated filename to be overwritten with a parameter.
Expand Down
Loading

0 comments on commit 3dab18c

Please sign in to comment.