Drawing in ASCII

Author

Dheepak Krishnamurthy

Published

June 5, 2020

Keywords

ascii, svgbob, pandoc, filter, lua, circuit, diagrams

We can define a lua filter for pandoc that takes a code block that has the language defined as render_svgbob, and passes the text inside that code block to svgbob.

Here is a simple 3-bus circuit diagram using text / ascii:

svgbob"""
           |           +-----------+           |
           +-----------+           +-----------+
           |           +-----------+           |
     +-----+1               y12               2+------+
     |     |                                   |      |
     |     +-+                               +-+      |
   .-+-.   |  \                             /  |    .-+-.
   |   |       \                           /        |   |
   |   |y1    .-+-.                     .-+-.     y2|   |
   '-+-'       \   \ y13          y23  /   /        '-+-'
     |          \   \                 /   /           |
     |           '-+-'               '-+-'            |
  -------           \                 /            -------
    ---              +               +               ---
     -               |        3      |                -
                  ---+-------+-------+---
                             |
                           .-+-.
                           |   |
                           |   |y3
                           '-+-'
                             |
                             |
                          -------
                           -----
                             -
"""

Reuse

Citation

BibTeX citation:
@online{krishnamurthy2020,
  author = {Krishnamurthy, Dheepak},
  title = {Drawing in {ASCII}},
  date = {2020-06-05},
  url = {https://kdheepak.com/blog/drawing-in-ascii/},
  langid = {en}
}
For attribution, please cite this work as:
D. Krishnamurthy, “Drawing in ASCII,” Jun. 05, 2020. https://kdheepak.com/blog/drawing-in-ascii/.