Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ggerganov/dot-to-ascii
Graphviz to ASCII converter using Graph::Easy
https://github.com/ggerganov/dot-to-ascii
ascii converter dot graphviz
Last synced: about 15 hours ago
JSON representation
Graphviz to ASCII converter using Graph::Easy
- Host: GitHub
- URL: https://github.com/ggerganov/dot-to-ascii
- Owner: ggerganov
- License: mit
- Created: 2019-11-30T14:27:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2022-06-27T10:39:38.000Z (over 2 years ago)
- Last Synced: 2024-10-03T13:51:12.762Z (2 months ago)
- Topics: ascii, converter, dot, graphviz
- Language: HTML
- Homepage: https://dot-to-ascii.ggerganov.com
- Size: 48.8 KB
- Stars: 444
- Watchers: 13
- Forks: 20
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# dot-to-ascii
Try it here: https://dot-to-ascii.ggerganov.com
![dot-to-ascii](https://i.imgur.com/3WLVWn3.png)
## How it works?
- The [index.html](index.html#L82-L95) page sends XHR requests containing your Graphviz input to the [dot-to-ascii.php](dot-to-ascii.php) script
- The [dot-to-ascii.php](dot-to-ascii.php#L8) script runs the [Graph::Easy](https://metacpan.org/pod/Graph::Easy) command line tool to produce a text diagram from the provided Graphviz input
- The result is returned back to [index.html](index.html#L82-L95) where it is displayed in a `` tag## API
Dot-to-ascii can be easily used in your code by performing https requests to the api.
### Python
```python
import requestsdef dot_to_ascii(dot: str, fancy: bool = True):
url = 'https://dot-to-ascii.ggerganov.com/dot-to-ascii.php'
boxart = 0# use nice box drawing char instead of + , | , -
if fancy:
boxart = 1params = {
'boxart': boxart,
'src': dot,
}response = requests.get(url, params=params).text
if response == '':
raise SyntaxError('DOT string is not formatted correctly')return response
`````` python
graph_dot = '''
graph {
rankdir=LR
0 -- {1 2}
1 -- {2}
2 -- {0 1 3}
3
}
'''graph_ascii = dot_to_ascii(graph_dot)
print(graph_ascii)
``````
┌─────────┐
│ │
┌───┐ ┌───┐ ┌───┐ ┌───┐
┌─ │ 0 │ ─── │ 1 │ ─── │ │ ─── │ 3 │
│ └───┘ └───┘ │ │ └───┘
│ │ │ │
│ └──────────────── │ 2 │
│ │ │
│ │ │
└───────────────────── │ │
└───┘
```## Run locally with docker
This uses the minimal Dockerfile with the default apache config etc. Not
suitable for production use.``` bash
$ docker build -t dot-to-ascii .
$ docker run --rm -d --name dot-to-ascii -p 8080:80 dot-to-ascii
$ # open localhost:8080 in your browser
```