Code Monkey home page Code Monkey logo

remark-graphviz-svg's Introduction

remark-graphviz-svg

Version

A remark plugin to convert GraphViz code into SVG diagram

Features

  • Custom language name for code blocks
  • Support different GraphViz engines
  • SVG Optimization using svgo

Installation

npm install remark-graphviz-svg

Note: This package uses ESM. Use Node 12+ and ESM import syntax to use this package.

Usage

import remarkParse from "remark-parse";
import remarkRehype from "remark-rehype";
import rehypeStringify from "rehype-stringify";
import { remarkGraphvizSvg } from "remark-graphviz-svg";
import fs from "fs";

const processor = unified()
  .use(remarkParse)
  .use(remarkGraphvizSvg)
  .use(remarkRehype)
  .use(rehypeStringify);

const content = await processor.process(
  fs.readFileSync("example.md")
);

console.log(content.value);

Suppose the example.md has the following content:

# Hello, world

```graphviz
digraph {
  A -> B
}
```

Then the output of the above code is similar to the following:

<h1>Hello, world</h1>
<p>
  <svg><!-- generated svg --></svg>
</p>

Options

  • language: Render GraphViz diagrams on specific language blocks. (Default: graphviz)
  • graphvizEngine: GraphViz engine to use. See available engines here. (Default: dot)
  • svgoOptions: Override default svgo options. Set it to null to disable svgo. (Default: defaultSvgoOptions)

License

GPL-3.0

remark-graphviz-svg's People

Contributors

dcsunset avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.