Convert your ascii diagram scribbles into happy little SVG

Overview

Svgbob

svgbob’s current version badge

Svgbob can create a nice graphical representation of your text diagrams.

Svgbob provides a cli which takes text as an input and creates an svg image as an output.

Demo

Specification

Donate using Liberapay

Comments
  • Ability to style diagram

    Ability to style diagram

    Raising this out of this thread to not digress too much.

    Should svgbob allow the ability to style nodes? It would be nice to be able to do it so that diagrams can be represented in text and still support colour. The ascii version of the diagram is not very readable with styling information included in each node. @ivanceras gave an example of using single letters to represent colour, but I foresee potential use cases for additional styling.

    I've copied a bit of the post and edited it to see what it may look like:

     .---------.            .-----------.
    ( Alice {a} )  ---->   / Bob {b,c} /
     `---------'          '-----------'
    
     .---------.            .----------.
    ( Apple {a} )  ---->   / Ball {b} /
     `---------'          '----------'
    
    # Legend:
    
    a: { color: red }
    b: { color: blue }
    c: { opacity: 0.5 }
    

    Also, what about people wanting to style lines? Maybe we leave that as a separate topic.

    enhancement 
    opened by azriel91 25
  • Avoid converting words to symbols

    Avoid converting words to symbols

    In some cases svgbob will take a letter inside a word and transform it to a symbol instead for letting it be a character that's part of the word; the examples I have seen where mainly with V, inside a word, be transformed in a down arrow.

    svg bob could do a first pass and mark, with the help of a dictionary, the character that are not to be transformed, it should also be possible to input wors or whole dictionary of word to use if one has a technical name not part of the dictionary or uses a foreign language.

    opened by nkh 9
  • Allow dashes and underscores within words

    Allow dashes and underscores within words

    What

    Words should be able to contain underscores and dashes.

    E.g. these should be rendered as text, not lines: product_id, 2019-10-31, +10-15V. A good test case is the product table in demo.bob.

    How

    This PR achieves this by

    • adding all alphanumeric characters to ascii_map.rs and subsequently
    • checking whether the characters to the left or the right are alphanumeric.

    Result

    Old product table: demo_bad_dashes New product table: demo_good_dashes

    Improvements in product table:

    • product_id and other headers
    • dates
    • serial keys, somewhat

    Selected other improvements:

    • circuits.bob, demo.bob: +10-15V
    • long.bob: Derived_A, FS-Cache, e-mails, 1M-1Watt

    There are no negative effects for the examples.

    Possible further improvements

    • Extend to (, ), /, :.
    • Do something smarter than adding all letters and digits to ascii_map.rs.
    • Add proper tests.
    opened by hugobuddel 7
  • Crossing diagonals

    Crossing diagonals

    Hello !

    Is there a way to display crossing diagonals ? Example:

    ------------.                
                 \ .-------------
                  \              
                 / '------------>
    ------------'                
    

    The diagonal crossing is incomplete. It would be nice to have access to X for that job:

    ------------.                
                 \ .-------------
                  X              
                 / '------------>
    ------------'                
    

    Thanks,

    opened by xguerin 6
  • Command line stdin conversion

    Command line stdin conversion

    I would like to make a pandoc filter that does basically what spongedown does with ascii drawings. But I can't find how to properly pass a multiline string to svgbob through the command line. How is this done ?

    On Windows, I have tried things like : echo "+--+\n| |\n+--+" | svgbob but the \n are kept as they are, and trying to pass the raw string from python actually ends the command in the middle of the string, effectively yielding an echo of the first line of the drawing.

    opened by yhql 6
  • Svg file returned from url

    Svg file returned from url

    What would be useful would be a method of returning a svg image from a request URL containing the source text, similar to SciWeavers site to return an image from Latex text (http://www.sciweavers.org/tex2img.php?eq=\sum_{i=1}^{n}x_{i}^{2}&bc=cornsilk&fc=black&im=jpg&fs=24&ff=arev).

    Latex

    opened by billthefarmer 5
  • Width of CJK character change when line contains escaped chars

    Width of CJK character change when line contains escaped chars

    Normally one CJK character equal two english character width, the following will be closed.

    +----+
    | 一 |
    +----+
    

    If the line contains escape qutoe, the CJK character seems need 3 english character spaces to get the shape closed.

    +--------+
    |"""一"""|
    +--------+
    

    I am using svgbob 0.3.2.

    bug 
    opened by QiangF 5
  • add support to escape char

    add support to escape char

    Sometime a char is treated as diagram char when it was intended to be word char.

    Example 1:

    co-edit
    single-person
    

    Is rendered as: 1 The hyphen after o is treated as a horizontal line.

    Example 2:

    (some remark)
    
    some text
    (some remark)
    some text
    

    Is rendered as: 2 The open bracket between lines is rendered as a diagram which the close bracket is still rendered as text.

    opened by beenotung 5
  • Difference in rendering with old elm example

    Difference in rendering with old elm example

    Hi,

    I notice a different rendering of the sequence:

                          .      \ \ '--- The::Latest
                         /|       \ \      \
     With::Some::fantasy  '        \ \      '---- The::Latest::Greatest
                         /|         \ \
             More::Stuff  '          \ '- I::Am::Running::Out::Of::Ideas
                         /|           \
             More::Stuff  '            \
                         /              '--- Last::One
             More::Stuff 
    

    in svgbob and https://ivanceras.github.io/elm-examples/elm-bot-lines/

    In a terminal the use of quote "'" rather than dot "." looks better in ASCII. Could you unify the rendering so both render the same way

    If you think I am picky and have an hawk eye, it's because I have drawn most of the example you use in the old version and they grabbed my eye today when I saw this project for the first time.

    I think I may steal from you one or two stencils, I like the circles rendering, in fact I like this project very much.

    opened by nkh 5
  • Escaping characters to have them

    Escaping characters to have them "verbatim"?

    Hi there! Awesome project. I wanted to ask if it is possible to somehow tell renderer that "this character is just text"? I am trying to render Ruby's object diagram from the official book:

                                 +---------+             +-...
                                 |         |             |
                 BasicObject-----|-->(BasicObject)-------|-...
                     ^           |         ^             |
                     |           |         |             |
                  Object---------|----->(Object)---------|-...
                     ^           |         ^             |
                     |           |         |             |
                     +-------+   |         +--------+    |
                     |       |   |         |        |    |
                     |    Module-|---------|--->(Module)-|-...
                     |       ^   |         |        ^    |
                     |       |   |         |        |    |
                     |     Class-|---------|---->(Class)-|-...
                     |       ^   |         |        ^    |
                     |       +---+         |        +----+
                     |                     |
        obj--->OtherClass---------->(OtherClass)-----------...
    

    ...and the SvgBobRus understands it pretty well, but replaces most of the "O"s with special symbols (note also it can't guess two arrows under the "Class" at the bottom): image

    opened by zverok 5
  • Converting to PNG(using rsvg-convert) drops lines

    Converting to PNG(using rsvg-convert) drops lines

    Problem

    With using rsvglib(as rsvg-convert) on Mac, conversion is not great; output is dropping "lines". I am not sure this is rsvglib matter or svgbob.

    Conditions

    • MacOS
    • svgbob 0.3.1
    • rsvg-convert version 2.40.16

    Input

    input.txt:

                   o VDD
                   |
                  +++
                  | |
                  +++    +
      THRESHOLD    |   + |\    +-------+                 +
      o------------------+ \   |       |                 |\
                   |     |  +--| R     |                 | \
                   *-----+ /   |       | +---------------+  +o----------o
                   |   - |/    |       | |               | /  OUTPUT
                  +++    +     |       | |               |/
                  | |          |       | |               +
                  +++    +     |       | |     o DISCHARGE
                   |   + |\    |       | |     |
                   *-----+ \   |       | |   |'
      nTRIGGER     |     |  +--| S  nQ o-*---+  NPN
      o------------------+ /   |       |     |`>
                   |   - |/    +---o---+       |
                  +++    +         |           |
                  | |              |           |
                  +++              |           |
                   |               |           |
                   *---------------------------+
                   |               |
                   o GND           |
      nRESET                       |
      o----------------------------+
    
    

    $ input.txt -o svg.svg $ rsvg-convert -f png svg.svg -o png.png

    Output

    SVG output(screenshot) is great like 2018-09-25 22 48 07 while conversion to png is like png

    visual-bug 
    opened by K4zuki 4
  • Question: Change text color

    Question: Change text color

    Hey, just stumbled over this and it looks great! Wondering if one can change the color of the text easily. As far as I understood the configuration of a class like {foo} is applied to the shape. Could there be something like {text:foo} to be able to set color for the text?

    Thanks a ton and feel free to close if not a good question (or I was simply to blind to figure things out!).

    opened by spinscale 0
  • Fails to parse quoting at end of line

    Fails to parse quoting at end of line

    Here is a minimal example:

    -- "(A)"
    

    which gives bild

    And this is a greater example:

                     o--------------o------o "(A)"
                    /
        "(E)" o----o
                            o
                            |
                            | "(M)"
    
    
                                    o------o "(A)"
    
    
        "(E)" o----o-o---------------
                            o
                            |
                            | "(M)"
    

    which gives bild

    svgbob --version => svgbob 0.6.2

    opened by jo-so 0
  • add docker image

    add docker image

    To easier the trial, It would be nice to have a docker image. language-independent docker imege makes it much easier to use with CI. (e.g. gitlab, jenkins)

    https://github.com/ivanceras/svgbob/issues/93

    screenshot

    image

    opened by arukiidou 1
  • To easier the trial, add docker image

    To easier the trial, add docker image

    For users unfamiliar in Rust, getting started with svgbob takes a bit of work.

    To easier the trial, It would be nice to have a docker image. language-independent docker imege makes it much easier to use with CI. (e.g. gitlab, jenkins)

    Until an official image registry is created, the following unofficial image registry has been prepared. If possible, an official image registry would be better.

    docker hub unofficial image

    https://hub.docker.com/r/arukiidou/svgbob_cli

    opened by arukiidou 0
  • Triangle filling is not working

    Triangle filling is not working

    Hi,

    I've tried to fill a triangle, but it does not work.

    This is my testcase:

    +---+ +-----+ + +---------+ +
    |{r}|  \{r}/ / \ \       / / \
    +---+   \ / /{r}\ \ {r} / /   \
             + +-----+ \   / / {r} \
    +-----+             \ / /       \
    |     |              + +---------+
    | {r} |
    |     |
    +-----+
    
    # Legend:
    r = {
        fill: red;
    }
    

    test

    opened by kingelilol 1
  • Syntax for an arc

    Syntax for an arc

    Would it be possible to extend the syntax to draw an arc?

            +
           / \            "This would draw a sharp corner"
          /   v
    
            .
           / \            "This would dar an arc (a dot at the point where edges meet)"
          /   v
    
            .-.
           /   \          "This is the current way to draw something like an arc"
          /     v
    

    test

    wontfix 
    opened by jo-so 2
Releases(0.5.5)
Owner
Jovansonlee Cesar
Rust programmer, library creator, blockchain enthusiast.
Jovansonlee Cesar
Convert UFO .glif files to SVG, whether they're part of a font or not

Convert UFO glyph files (.glif) to SVG There exists already an svg2glif, but for some reason not the opposite operation. My MFEKglif editor treats .gl

Modular Font Editor K 3 Apr 26, 2022
Use free svg icons in your Dioxus projects easily with dioxus-free-icons.

dioxus-free-icons Use free svg icons in your Dioxus projects easily with dioxus-free-icons. More information about this crate can be found in the crat

Daiki Nishikawa 16 Jan 2, 2023
🔭 Annict での今期の視聴状況を SVG 画像として出力するサーバ (WIP)

annict-profile-card ?? Annict の視聴状況などを SVG 画像として出力する API サーバ (WIP) Annict GraphQL API を使用しています。

Nep 16 Dec 20, 2022
resvg is an SVG rendering library.

resvg can be used as a Rust library, a C library and as a CLI application to render SVG files based on a static SVG Full 1.1 subset.

Evgeniy Reizner 1.8k Dec 30, 2022
An SVG toolkit based on resvg

rusty-svg An SVG toolkit based on resvg This module is compiled to WASM and currently only supports Node.js Comparing with the backend ReSVG, this mod

Zimon Dai 9 Mar 21, 2022
The tool to make svg with triangles by length from two points.

The tool to make svg with triangles by length from two points.

null 2 Sep 27, 2021
A Rust-implementation of devout’s tutorial to create an SVG graphic device using extendr.

A Rust-implementation of devout’s tutorial to create an SVG graphic device using extendr.

Hiroaki Yutani 1 Jan 25, 2022
A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls!

regretti ?? A programming language where comments are the first-class citizen and ASCII art flowcharts are the controls! Made for Lang Jam (jam0001) t

Mufeed VH 15 Dec 27, 2022
A Simple Image to Ascii converter in Rust

Image to Ascii A Simple Image to Ascii converter in Rust Brief ?? In my way to learn Rust i decided to make this converter. Challenges ?? new to Rust

WasixXD 7 Sep 16, 2022
CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console)

CLI and utilities for converting media files (images/videos) to ascii outputs (output media file or print to console). Supports most standard image formats, and some video formats.

Michael 30 Jan 1, 2023
Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format.

RDR2 Screenshot converter Convert and save photomode screenshots from Red Dead Redemption 2 to JPEG format. QuickStart Just download the executable fi

Timofey Gelazoniya 12 Sep 29, 2022
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

Harrison Burt 242 Dec 22, 2022
convert markdown headers to graph

Rust Markdown to graph This program converts a Markdown file into a graph. For now, it creates .dot file which graphviz uses to build graph. It transl

null 3 Sep 26, 2021
Convert Sketchbook Tiff Files to Open Raster Images

SketchbookTiffConverter Convert Sketchbook Tiff Files to Open Raster Images and retain layer information. This is a command line program that will con

Phil Spindler 3 Nov 2, 2021
Converts images into textual line art.

img2utf Transform images to textual line art! Images require pre-processing to come out nice. It's expected that users will do the following: Apply ga

Lee 149 Dec 10, 2022
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

EmojiPix This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art vers

Michael Milton 22 Dec 6, 2022
🖼️Combines a Javascript and WASM file into a single executable polygot PNG+HTML file.

WASIMAGE Combines a Javascript and WASM file into a single executable polygot PNG+HTML file. Usage: cargo install wasimage wasimage --wasm-file my.was

Nervive 2 Mar 30, 2022
A cross-platform tool for embedding GPS data into photographs

nya-exif 中文 | English 介绍 nya-exif 是一个用于匹配照片 GPS 信息, 并写入文件 EXIF 信息的工具, 支持 JPEG 和 PNG 及各大相机厂商的主流RAW格式. 本工具基于 Rust 编写, 支持全平台使用 Features 支持 JPEG 和 PNG 及各大

Lyn Chen 32 Nov 16, 2023
A more compact and intuitive ASCII table in your terminal: an alternative to "man 7 ascii" and "ascii"

asciit A more compact and intuitive ASCII table in your terminal: an alternative to man 7 ascii and ascii. Colored numbers and letters are much more e

Qichen Liu 刘启辰 5 Nov 16, 2023
tai (Terminal Ascii Image) tool to convert images to ascii written in Rust

TAI Terminal Ascii Image A tool to convert images to ascii art written in Rust ?? Notes This tool is still in development stage. Contributions All Con

Mustafa Salih 258 Dec 5, 2022