/remark-kroki

Kroki plugin of remark

Primary LanguageJavaScriptMIT LicenseMIT

remark-kroki

Kroki plugin of remark.

npm github node

Installation

npm install remark-kroki --save-dev

Usage

import readFileSync from 'fs';

import { remark } from 'remark';
import { remarkKroki } from 'remark-kroki';

const markdownText = readFileSync('example.md', 'utf8');

remark()
  .use(remarkKroki, {
    server: 'http://localhost:8000',
    alias: ['plantuml']
  })
  .process(markdownText)
  .then((file) => console.info(file))
  .catch((error) => console.warn(error));

Options

Options.server

Using self host server by default. Set https://kroki.io to use free service.

Options.headers

  • type: object

HTTP headers to send to the server for custom authentication.

Options.alias

  • type: array
  • example: ['plantuml']

Alias code language name to treat as kroki code block, meta.type will be ignored.

Syntax

Turn

```kroki type=plantuml
  A --> B
```

Into

![plantuml](data:image/svg+xml;base64,xxxxxxxx)
Turn

```kroki type=plantuml alt=abc
  A --> B
```

Into

![abc](data:image/svg+xml;base64,xxxxxxxx)

Alias

```kroki type=plantuml
```
 ↓
```plantuml
```

Related