kroki 0.0.4 copy "kroki: ^0.0.4" to clipboard
kroki: ^0.0.4 copied to clipboard

Class for accessing Kroki.io web service for diagram syntax to svg rendering.

Kroki.dart #

Pub pub points popularity likes License

GitHub contributors GitHub forks GitHub stars

This is a simple class to package up and send requests to the Kroki.io web service.

A live editor to editing diagrams that Kroki supports can be found at niolesk.top

Features and bugs #

Please file feature requests and bugs at the issue tracker.


Example with package:markdown #

Here is an example of using the Kroki package with package:markdown to support fenced code blocks that contain diagrams.

import 'package:kroki/kroki.dart';
import 'package:markdown/markdown.dart' as markdown;

final Kroki kroki = Kroki();

class DiagramTransfomer extends markdown.CodeBlockTransformer {
  @override
  markdown.Node? transformCodeBlock(
      String codeBlockType, String rawCodeBlock, markdown.BlockParser parser) {
    final markdown.AsyncText asyncText = markdown.AsyncText(
        kroki.convertDiagram(codeBlockType, rawCodeBlock), parser,
        uncompletedFutureTextValue:
            rawCodeBlock // fall back to showing diagram source
        );
    return asyncText;
  }

  DiagramTransfomer() :
    super(handledCodeBlockTypes:KrokiDiagramEndpoints.supportedEndpoints);
}

final diagramTransformingFencedCodeBlock =
    markdown.TransformableFencedCodeBlockSyntax([DiagramTransfomer()]);

main() {
    final finalHtml = await markdown.markdownToHtmlWithAsyncTransforms(markdownSource,
      blockSyntaxes: [diagramTransformingFencedCodeBlock],
      extensionSet: markdown.ExtensionSet.gitHubWeb);
}   

final String markdownSource = r'''
# Example mermaid diagram

```mermaid
graph TD;
    A-->B;
    A-->C;
    B-->D;
    C-->D;
```
''';

 
7
likes
140
points
58
downloads

Publisher

verified publisherhiveright.tech

Weekly Downloads

Class for accessing Kroki.io web service for diagram syntax to svg rendering.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

archive, crypto, http

More

Packages that depend on kroki