prettier-plugin-dot

A prettier plugin for Graphviz Dot.

Usage no npm install needed!

<script type="module">
  import prettierPluginDot from 'https://cdn.skypack.dev/prettier-plugin-dot';
</script>

README

NodeCI npm version License: MIT PRs Welcome tested with jest code style: prettier Open in Visual Studio Code All Contributors

Prettier for Graphviz Dot

prettier-plugin-dot is a prettier plugin for Graphviz Dot.

Format your Dot using Prettier.

How it works

A Prettier plugin must first parse the source code of the target language into a traversable data structure (Usually an Abstract Syntax Tree) and then print out that data structure in a "pretty" style.

The Graphviz Dot AST generated by @ts-graphviz/parser implemented in JavaScript using the peggy. What this means is that unlike many other prettier plugins, prettier-plugin-dot has no additional runtime pre-requisites (e.g: Python executable). It could even be used inside a browser.

Getting started

If you're using the npm or yarn CLI, then add the plugin by:

NPM

# yarn
$ yarn add -D prettier prettier-plugin-dot
# or npm
$ npm install --save-dev prettier prettier-plugin-dot

The prettier executable is now installed and ready for use:

$ yarn run prettier --write '**/*.dot'
# or
$ npx prettier --write '**/*.dot'

Example

Input

digraph G {Hello->World}

Output

digraph G {
  Hello -> World;
}

See Also

Graphviz-dot Test and Integration

Contributors

Thanks goes to these wonderful people (emoji key):


Yuki Yamazaki

📖 ⚠️ 💻

Chris Wilkinson

🐛

Irakli Safareli

🤔

This project follows the all-contributors specification. Contributions of any kind welcome!

License

This software is released under the MIT License, see LICENSE.