sitnikovv / dot-to-ascii

Graphviz to ASCII converter using Graph::Easy

Home Page:https://dot-to-ascii.ggerganov.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

dot-to-ascii

Try it here: https://dot-to-ascii.ggerganov.com

dot-to-ascii

Examples Usage

Dot-to-ascii can be easily used in your code by performing https requests to the api.

Python

import requests


def 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 = 1

    params = {
        'boxart': boxart,
        'src': dot,
    }

    response = requests.get(url, params=params).text

    if response == '':
        raise SyntaxError('DOT string is not formatted correctly')

    return response
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 │
  │                      │   │
  │                      │   │
  └───────────────────── │   │
                         └───┘

About

Graphviz to ASCII converter using Graph::Easy

https://dot-to-ascii.ggerganov.com


Languages

Language:HTML 66.0%Language:CSS 15.8%Language:PHP 11.9%Language:JavaScript 6.3%