Coder Social home page Coder Social logo

arthursonzogni / diagon Goto Github PK

View Code? Open in Web Editor NEW
1.4K 13.0 54.0 527 KB

Interactive ASCII art diagram generators. :star2:

Home Page: https://arthursonzogni.com/Diagon/

License: MIT License

CMake 5.46% HTML 6.44% C++ 82.15% ANTLR 2.29% CSS 3.47% Shell 0.19%
ascii-art webassembly cpp webapp webapplication generators parser lexer antlr cmake

diagon's Introduction

Diagon

logo

Diagon is an interactive interpreter. It transforms markdown-style expression into an ascii-art representation.

It is written in C++ and use WebAssembly, HTML and CSS to make a Web Application. We also expose a command line interface and a JS library, for personal and 3rd party tools.

Web application

https://arthursonzogni.com/Diagon/

Command line interface

Diagon is also usable as a command line tool. For instance:

echo "1+1/2 + sum(i,0,10) = 113/2" | diagon Math
            10         
          ___        
      1   ╲       113
  1 + ─ + ╱   i = ───
      2   ‾‾‾      2 
           0         

To use it, you can either compile it from source or use the precompiled binaries published on the snapstore:

sudo snap install diagon

snapstore Get it from the Snap Store

It is also available as a Nix package:

nix run github:petertrotman/nixpkgs/Diagon#diagon

(A pull request is open to have this merged into NixOS/nixpkgs here)

Javascript library

See the JS library diagonjs

npm i diagonjs
import Diagon from "diagonjs";
const diagon = await Diagon.init();
diagon.translate.math("f(x) = 1 + x / (1 + x)", { style: "Unicode" });

//               x
// f(x) = 1 + ─────
//            1 + x

IDE plugins

Make diagon easy to use inside your IDE. Thanks to contributors:

Table of content

Generators

Mathematic Expression

Mathematic Expression

input:

f(x) = 1 + x / (1 + x)

output (Unicode):

             x  
f(x) = 1 + ─────
           1 + x

input:

sqrt(1+sqrt(1+x/2))

output (Unicode)

     _____________
    ╱        _____
   ╱        ╱    x
  ╱  1 +   ╱ 1 + ─
╲╱       ╲╱      2

input:

f(x) = 1 + x^2 + x^3 + x^(1+1/2)

output (Unicode):

                      ⎛    1⎞
                      ⎜1 + ─⎟
            2    3    ⎝    2⎠
f(x) = 1 + x  + x  + x       

input:

sum(i^2,i=0,n) = n^3/2+n^2/2+n/6

output (Unicode):

  n                   
 ___        3    2    
 ╲     2   n    n    n
 ╱    i  = ── + ── + ─
 ‾‾‾        2    2   6
i = 0                 

input:

int(x^2/2 * dx ,0,1) = 1/6

output (Unicode):

1            
⌠  2         
⎮ x         1
⎮ ── ⋅ dx = ─
⌡  2        6
0            

input:

[a;b] + [c;d] = [a+c; b+d]

output (Unicode):

⎛a⎞   ⎛c⎞   ⎛a + c⎞
⎜ ⎟ + ⎜ ⎟ = ⎜     ⎟
⎝b⎠   ⎝d⎠   ⎝b + d⎠

input:

[1,2;3,4] * [x;y] = [1*x+2*y; 3*x+4*y]
⎛1 2⎞   ⎛x⎞   ⎛1 ⋅ x + 2 ⋅ y⎞
⎜   ⎟ ⋅ ⎜ ⎟ = ⎜             ⎟
⎝3 4⎠   ⎝y⎠   ⎝3 ⋅ x + 4 ⋅ y⎠
Sequence Diagram

Sequence Diagram

input

Alice -> Bob: Hello Bob!
Alice <- Bob: Hello Alice!

Output (Unicode)

┌─────┐       ┌───┐
│Alice│       │Bob│
└──┬──┘       └─┬─┘
   │            │  
   │ Hello Bob! │  
   │───────────>│  
   │            │  
   │Hello Alice!│  
   │<───────────│  
┌──┴──┐       ┌─┴─┐
│Alice│       │Bob│
└─────┘       └───┘

Input

Renderer -> Browser: BeginNavigation()
Browser -> Network: URLRequest()
Browser <- Network: URLResponse()
Renderer <- Browser: CommitNavigation()
Renderer -> Browser: DidCommitNavigation()

Output (Unicode)

 ┌────────┐            ┌───────┐     ┌───────┐
 │Renderer│            │Browser│     │Network│
 └───┬────┘            └───┬───┘     └───┬───┘
     │                     │             │    
     │  BeginNavigation()  │             │    
     │────────────────────>│             │    
     │                     │             │    
     │                     │URLRequest() │    
     │                     │────────────>│    
     │                     │             │    
     │                     │URLResponse()│    
     │                     │<────────────│    
     │                     │             │    
     │ CommitNavigation()  │             │    
     │<────────────────────│             │    
     │                     │             │    
     │DidCommitNavigation()│             │    
     │────────────────────>│             │    
 ┌───┴────┐            ┌───┴───┐     ┌───┴───┐
 │Renderer│            │Browser│     │Network│
 └────────┘            └───────┘     └───────┘

Input

1) Renderer -> Browser: Message 1
2) Renderer <- Browser: Message 2

Renderer: 1<2
Browser: 2<1

Output (Unicode)

 ┌────────┐┌───────┐
 │Renderer││Browser│
 └───┬────┘└───┬───┘
     │         │    
     │──┐      │    
     │Message 2│    
     │<────────│    
     │  │      │    
     │Message 1│    
     │  └─────>│    
 ┌───┴────┐┌───┴───┐
 │Renderer││Browser│
 └────────┘└───────┘
Tree

Tree

Input

Linux
  Android
  Debian
    Ubuntu
      Lubuntu
      Kubuntu
      Xubuntu
      Xubuntu
    Mint
  Centos
  Fedora

Output (Style Unicode 1)

Linux
 ├─Android
 ├─Debian
 │  ├─Ubuntu
 │  │  ├─Lubuntu
 │  │  ├─Kubuntu
 │  │  ├─Xubuntu
 │  │  └─Xubuntu
 │  └─Mint
 ├─Centos
 └─Fedora

Output (Style ASCII 2)

Linux
 +--Android
 +--Debian
 |   +--Ubuntu
 |   |   +--Lubuntu
 |   |   +--Kubuntu
 |   |   +--Xubuntu
 |   |   `--Xubuntu
 |   `--Mint
 +--Centos
 `--Fedora

Output (Style Unicode right top)

───Linux─┬─Android
         ├─Debian─┬─Ubuntu─┬─Lubuntu
         │        │        ├─Kubuntu
         │        │        ├─Xubuntu
         │        │        └─Xubuntu
         │        └─Mint
         ├─Centos
         └─Fedora

Output (Style Unicode right center)

         ┌─Android
         │                 ┌─Lubuntu
         │                 ├─Kubuntu
         ├─Debian─┬─Ubuntu─┼─Xubuntu
───Linux─┤        │        └─Xubuntu
         │        └─Mint
         ├─Centos
         └─Fedora
Frame

Frame

Input

#include <iostream>
using namespace std;

int main() 
{
    cout << "Hello, World!";
    return 0;
}

Output

┌─┬────────────────────────────┐
│1│#include <iostream>         │
│2│using namespace std;        │
│3│                            │
│4│int main()                  │
│5│{                           │
│6│    cout << "Hello, World!";│
│7│    return 0;               │
│8│}                           │
└─┴────────────────────────────┘
Table

Input

Column 1,Column 2,Column 3
C++,Web,Assembly
Javascript,CSS,HTML

Output (Style Unicode)

┌──────────┬────────┬────────┐
│Column 1  │Column 2│Column 3│
├──────────┼────────┼────────┤
│C++       │Web     │Assembly│
├──────────┼────────┼────────┤
│Javascript│CSS     │HTML    │
└──────────┴────────┴────────┘
GraphPlanar

GraphPlanar

Input

if -> "then A" -> end
if -> "then B" -> end
end -> loop -> if

Output (Unicode)

┌──────────┐     
│    if    │     
└△─┬──────┬┘     
 │ │     ┌▽─────┐
 │ │     │then A│
 │ │     └┬─────┘
 │┌▽─────┐│      
 ││then B││      
 │└┬─────┘│      
 │┌▽──────▽─┐    
 ││   end   │    
 │└┬────────┘    
┌┴─▽─┐           
│loop│           
└────┘           
GraphDAG

GraphDAG

Input:

socks -> shoes    
underwear -> shoes
underwear -> pants
pants -> shoes    
pants -> belt     
belt -> jacket    
shirt -> belt     
shirt -> tie      
tie -> jacket     

Output:

┌─────┐┌─────────┐┌─────┐     
│socks││underwear││shirt│     
└┬────┘└┬─┬──────┘└┬─┬──┘     
 │      │┌▽─────┐  │┌▽───────┐
 │      ││pants │  ││tie     │
 │      │└┬──┬──┘  │└┬───────┘
┌▽──────▽─▽┐┌▽─────▽┐│        
│shoes     ││belt   ││        
└──────────┘└┬──────┘│        
┌────────────▽───────▽┐       
│jacket               │       
└─────────────────────┘       

Input:

chrome -> content  
chrome -> blink    
chrome -> base     
                   
content -> blink   
content -> net     
content -> base    
                   
blink -> v8        
blink -> CC        
blink -> WTF       
blink -> skia      
blink -> base      
blink -> net       
                   
weblayer -> content
weblayer -> chrome 
weblayer -> base   
                   
net -> base        
WTF -> base        

Output

┌────────┐                     
│weblayer│                     
└┬─┬─┬───┘                     
 │ │┌▽────────────────────────┐
 │ ││chrome                   │
 │ │└┬─────┬─────────────────┬┘
 │┌▽─▽────┐│                 │ 
 ││content││                 │ 
 │└┬─┬─┬──┘│                 │ 
 │ │ │┌▽───▽──────────────┐  │ 
 │ │ ││blink              │  │ 
 │ │ │└┬──┬───┬─┬───┬───┬─┘  │ 
 │ │┌▽─▽┐┌▽──┐│┌▽─┐┌▽─┐┌▽───┐│ 
 │ ││net││WTF│││v8││CC││skia││ 
 │ │└┬──┘└┬──┘│└──┘└──┘└────┘│ 
┌▽─▽─▽────▽───▽──────────────▽┐
│base                         │
└─────────────────────────────┘

Input:

random -> pool_urbg              
random -> nonsecure_base         
random -> seed_sequence          
random -> distribution           
                                 
nonsecure_base -> pool_urbg      
nonsecure_base -> salted_seed_seq
                                 
seed_sequence -> pool_urbg       
seed_sequence -> salted_seed_seq 
seed_sequence -> seed_material   
                                 
distribution -> strings          
                                 
pool_urbg -> seed_material       
                                 
salted_seed_seq -> seed_material 
                                 
seed_material -> strings         

Output:

┌───────────────────────────────┐             
│random                         │             
└┬─────────────┬─────────────┬─┬┘             
┌▽───────────┐┌▽────────────┐│┌▽─────────────┐
│distribution││seed_sequence│││nonsecure_base│
└┬───────────┘└┬───┬───────┬┘│└┬┬────────────┘
 │             │  ┌│───────│─│─│┘             
 │ ┌───────────┘  ││       │ │┌┘              
 │ │┌─────────────▽▽┐┌─────▽─▽▽┐              
 │ ││salted_seed_seq││pool_urbg│              
 │ │└┬──────────────┘└┬────────┘              
 │┌▽─▽────────────────▽┐                      
 ││seed_material       │                      
 │└┬───────────────────┘                      
┌▽─▽────┐                                     
│strings│                                     
└───────┘                                     
Flowchart

Flowchart

Input:

if ("DO YOU UNDERSTAND FLOW CHARTS?")                
  "GOOD!";                                           
else if ("OKAY, YOU SEE THE LINE LABELED 'YES'?") {  
  if ("... AND YOU CAN SEE THE ONES LABELED 'NO'?") {
    "GOOD";                                          
  } else {                                           
    if ("BUT YOU JUST FOLLOWED THEM TWICE?")         
      noop;                                          
    else                                             
      noop;                                          
    "(THAT WASN'T A QUESTION)";                      
    "SCREW IT"                                       
  }                                                  
} else {                                             
  if ("BUT YOU SEE THE ONES LABELED 'NO'?") {        
    return "WAIT, WHAT?";                            
  } else {                                           
    "LISTEN.";                                       
    return "I HATE YOU";                             
  }                                                  
}                                                    
                                                     
"LET'S GO DRING";                                    
"HEY, I SHOULD TRY INSTALLING FREEBSD!"              

Output:

   _________________                                                              
  ╱                 ╲                                                     ┌─────┐ 
 ╱ DO YOU UNDERSTAND ╲____________________________________________________│GOOD!│ 
 ╲ FLOW CHARTS?      ╱yes                                                 └──┬──┘ 
  ╲_________________╱                                                        │    
           │no                                                               │    
  _________▽_________                    ______________________              │    
 ╱                   ╲                  ╱                      ╲    ┌────┐   │    
╱ OKAY, YOU SEE THE   ╲________________╱ ... AND YOU CAN SEE    ╲___│GOOD│   │    
╲ LINE LABELED 'YES'? ╱yes             ╲ THE ONES LABELED 'NO'? ╱yes└──┬─┘   │    
 ╲___________________╱                  ╲______________________╱       │     │    
           │no                                     │no                 │     │    
   ________▽_________                     _________▽__________         │     │    
  ╱                  ╲    ┌───────────┐  ╱                    ╲        │     │    
 ╱ BUT YOU SEE THE    ╲___│WAIT, WHAT?│ ╱ BUT YOU JUST         ╲___    │     │    
 ╲ ONES LABELED 'NO'? ╱yes└───────────┘ ╲ FOLLOWED THEM TWICE? ╱yes│   │     │    
  ╲__________________╱                   ╲____________________╱    │   │     │    
           │no                                     │no             │   │     │    
       ┌───▽───┐                                   │               │   │     │    
       │LISTEN.│                                   └───────┬───────┘   │     │    
       └───┬───┘                                    ┌──────▽─────┐     │     │    
     ┌─────▽────┐                                   │(THAT WASN'T│     │     │    
     │I HATE YOU│                                   │A QUESTION) │     │     │    
     └──────────┘                                   └──────┬─────┘     │     │    
                                                      ┌────▽───┐       │     │    
                                                      │SCREW IT│       │     │    
                                                      └────┬───┘       │     │    
                                                           └─────┬─────┘     │    
                                                                 │           │    
                                                                 └─────┬─────┘    
                                                               ┌───────▽──────┐   
                                                               │LET'S GO DRING│   
                                                               └───────┬──────┘   
                                                             ┌─────────▽─────────┐
                                                             │HEY, I SHOULD TRY  │
                                                             │INSTALLING FREEBSD!│
                                                             └───────────────────┘

Download packages

Binaries using multiple formats are provided in the release section.

Build

This depends on cmake, and libboost-graph-dev On Linux:

sudo apt install make libboost-graph-dev cmake default-jdk;
mkdir build;
cd build;
cmake .. -DCMAKE_BUILD_TYPE=Release
make -j
sudo make install 

Packaging status

Packaging status

diagon

Thanks

This project has been possible thanks to these great projects

diagon's People

Contributors

arthursonzogni avatar gitleptune avatar iwahbe avatar mmngreco avatar ojab avatar petertrotman avatar pythonicninja avatar tg-m avatar wendajiang avatar xwuupb avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

diagon's Issues

Support for comments

I love this tool and would love to support comments in the actual text and not the rendered output. Is this possible?

Latex output

I'd love to use Diagon in a project I want to make, similar to org-mode but with more modern syntax, output, and tooling. I love how Diagon parses expressions, and so I was wondering how easy it is to add more backends because I don't want to reinvent the wheel. I'm personally looking for:

  • ASCII (already implemented)
  • utf-8 (already implemented)
  • KaTeX/HTML
  • LaTeX

I've used the latter two a lot, so I'm pretty comfortable with them; if it's not too hard and isn't against the scope of the project I'd love to try and implement them.

Support for subscripts

Hi This looks like a really cool project.

I'm wondering whether there is support for subscrips?

Finite State Machine Support

Want to first say I love the project. I came across a scenario where I wanted to add a finite state machine and realized there wasn't support for it. I don't know if this is something of interest but just wanted to bring it up.

Double-struck Lettering Support for Math Conversions

This would allow for some way to convert a character like an R into an , especially useful when talking about sets.

I can think of a couple ways this could be implemented

  • Something like LaTeX's \mathbb{<character>} notation (e.g. bb(R))
  • Typing two of the same capital letter in a row with no space (e.g. RR , R RR R)

non destructive nvim plugin

Hey there, I really love the light weight feel of Diagon compared to other solutions. I wanted to have the possibility of using it in neovim with the ability to update existing diagrams in place.

So I developed a little plugin. It's very lightweight and in some cases a bit opinionated as to how things are rendered. Currently only math expressions and sequences are supported but if there's interest that can easily be extended.

Thought I'd share it here maybe someone else might find some interest and use:
https://github.com/McKean/diagon.nvim

Thanks again for this great tool!

CLI option?

Hiya, for... reasons... I tried loading up https://pomax.github.io/bezierinfo in Lynx, and realised that it would be very nice to see an ascii version of the ~250 LaTeX formulae pepper throughout the page, rather than seeing this:

image

Is there a way to invoke Diagon via the CLI, so it can be made part of a build chain, calling it on a .tex file and getting stdio output that can be used by "whatever was looking at stdio"?

E.g. I currently generate those svg images by effectively running xelatex 1a2b3c4d.tex && pdfcrop 1a2b3c4d.pdf && pdf2svg 1a2b3c4d-cropped.pdf && svgo 1a2b3c4d-cropped.svg && cp 1a2b3c4d-cropped.svg ../images/latex/1a2b3c4d.svg so create a secondary chain that runs Diagon would be super cool.

Idea for encapsulation in flowchart

Awesome project! I was looking to do some ascii diagramming to depict the execution flow in some python programs in vim. I am looking to capture the flow of the program as it executes to organize the design better. Specifically, I have the following flowcharge

'Start';                                                                                                                                                                    
'Set working directory';                                                                                                                                                    
'Call pipeline_function passing preprocessing_fn as argument';                                                                                                              
if ('Within pipeline function')                                                                                                                                             
    {                                                                                                                                                                       
    'Call tfxio.BeamRecordsCsvTFXIO with format, columns, schema';                                                                                                          
    'Read using beam.io.ReadFromText as bytes';                                                                                                                             
    'Decode bytes using tfxio';                                                                                                                                             
    'Make a raw dataset with raw data and TensorAdapterConfig()';                                                                                                           
    'Transform raw dataset using tft_beam.AnalyzeAndTransformDataset';                                                                                                      
    'Get transform_fn back from transformation';                                                                                                                            
    'Encode transform data using beam.FlatMapTuple';                                                                                                                        
    'Write it using beam.io.WriteToTFRecord';                                                                                                                               
    'Write transform_fn using tft_beam.WriteTransformFn';                                                                                                                   
    return 'stuff';                                                                                                                                                         
    }                                                      
else {                                                                                                                                                                  
    'Get transform output using tft.TFTransformOutput';                                                                                                                     
    'Get single example from raw data, make batch';                                                                                                                         
    'Get tft_layer using transform_output.transform_features_layer()';                                                                                                      
    'Transform single example using tft_layer(single_example_batched)';                                                                                                     
    'Inspect transformed example to show names, datatypes, and shapes';                                                                                                     
    }                                                                                                                                                                       
    'End';                

This produces the following flowchart:

                   ┌─────┐                                                                                                                                                                                                                                                                                                      
                   │Start│                                                                                                                                                                                                                                                                                                      
                   └──┬──┘                                                                                                                                                                                                                                                                                                      
           ┌──────────▽──────────┐                                                                                                                                                                                                                                                                                              
           │Set working directory│                                                                                                                                                                                                                                                                                              
           └──────────┬──────────┘                                                                                                                                                                                                                                                                                              
      ┌───────────────▽──────────────┐                                                                                                                                                                                                                                                                                          
      │Call pipeline_function passing│                                                                                                                                                                                                                                                                                          
      │preprocessing_fn as argument  │                                                                                                                                                                                                                                                                                          
      └───────────────┬──────────────┘                                                                                                                                                                                                                                                                                          
               ____▽____                 ┌──────────────────────────────┐                                                                                                                                                                                                                                                       
              ╱               ╲                │Call tfxio.BeamRecordsCsvTFXIO│                                                                                                                                                                                                                                                 
             ╱ Within pipeline ╲_______________│with format, columns, schema  │                                                                                                                                                                                                                                                 
             ╲ function        ╱yes            └───────────────┬──────────────┘                                                                                                                                                                                                                                                 
              ╲_______________╱                 ┌──────────────▽──────────────┐                                                                                                                                                                                                                                                 
                      │no                       │Read using                   │                                                                                                                                                                                                                                                 
        ┌─────────────▽────────────┐            │beam.io.ReadFromText as bytes│                                                                                                                                                                                                                                                 
        │Get transform output using│            └──────────────┬──────────────┘                                                                                                                                                                                                                                                 
        │tft.TFTransformOutput     │                    ┌──────▽─────┐                                                                                                                                                                                                                                                          
        └─────────────┬────────────┘                    │Decode bytes│                                                                                                                                                                                                                                                          
          ┌───────────▽───────────┐                     │using tfxio │                                                                                                                                                                                                                                                          
          │Get single example from│                     └──────┬─────┘                                                                                                                                                                                                                                                          
          │raw data, make batch   │            ┌───────────────▽──────────────┐                                                                                                                                                                                                                                                 
          └───────────┬───────────┘            │Make a raw dataset with raw   │                                                                                                                                                                                                                                                 
┌─────────────────────▽─────────────────────┐  │data and TensorAdapterConfig()│                                                                                                                                                                                                                                                 
│Get tft_layer using                        │  └───────────────┬──────────────┘                                                                                                                                                                                                                                                 
│transform_output.transform_features_layer()│┌─────────────────▽─────────────────┐                                                                                                                                                                                                                                              
└─────────────────────┬─────────────────────┘│Transform raw dataset using        │                                                                                                                                                                                                                                              
     ┌────────────────▽────────────────┐     │tft_beam.AnalyzeAndTransformDataset│                                                                                                                                                                                                                                              
     │Transform single example using   │     └─────────────────┬─────────────────┘                                                                                                                                                                                                                                              
     │tft_layer(single_example_batched)│            ┌──────────▽──────────┐                                                                                                                                                                                                                                                     
     └────────────────┬────────────────┘            │Get transform_fn back│                                                                                                                                                                                                                                                     
          ┌───────────▽──────────┐                  │from transformation  │                                                                                                                                                                                                                                                     
          │Inspect transformed   │                  └──────────┬──────────┘                                                                                                                                                                                                                                                     
          │example to show names,│                 ┌───────────▽───────────┐                                                                                                                                                                                                                                                    
          │datatypes, and shapes │                 │Encode transform data  │                                                                                                                                                                                                                                                    
          └───────────┬──────────┘                 │using beam.FlatMapTuple│                                                                                                                                                                                                                                                    
                      │                            └───────────┬───────────┘                                                                                                                                                                                                                                                    
                      │                            ┌───────────▽───────────┐                                                                                                                                                                                                                                                    
                      │                            │Write it using         │                                                                                                                                                                                                                                                    
                      │                            │beam.io.WriteToTFRecord│                                                                                                                                                                                                                                                    
                      │                            └───────────┬───────────┘                                                                                                                                                                                                                                                    
                      │                           ┌────────────▽────────────┐                                                                                                                                                                                                                                                   
                      │                           │Write transform_fn using │                                                                                                                                                                                                                                                   
                      │                           │tft_beam.WriteTransformFn│                                                                                                                                                                                                                                                   
                      │                           └────────────┬────────────┘                                                                                                                                                                                                                                                   
                      │                                     ┌──▽──┐                                                                                                                                                                                                                                                             
                      │                                     │stuff│                                                                                                                                                                                                                                                             
                      │                                     └─────┘                                                                                                                                                                                                                                                             
                      │                                                                                                                                                                                                                                                                                                         
                    ┌─▽─┐                                                                                                                                                                                                                                                                                                       
                    │End│                                                                                                                                                                                                                                                                                                       
                    └───┘                                                                                                           

Right off the bat, this is really good and helpful. As you can see, I am trying to depict what's happening inside the pipeline function using a conditional. Probably not what you intended, and if there's a better way, please let me know. What I'd like to do is to be able to encapsulate/abstract the details that when needed. I was thinking of two ways that this could be done.

The first is to continue the left branch only after "stuff" is returned by the pipeline function. This way, I can fold the text in vim to abstract the details if needed.

A second option is to allow for the branch to be rendered horizontally, so that if I want to go into the details, I can navigate in the text editor horizontally.

Thanks for this excellent project!

Sequence: send message to itself or polling

Often times, I need to send a message to itself or polling and in which case I need to do A -> A: polling, something like this:

┌─┐
│A│
└┬┘
 │
 │Polling
 │-----+
 │     |
 │<----+
 │
┌┴┐
│A│
└─┘

However, it seems it does not work here:

$ diagon Sequence -- "A -> A: polling"
Something went wrong!
free(): invalid next size (normal)
Aborted

Security vulnerabilities

Hello, the Cisco Talos team found a security vulnerability affecting Diagon. As this is a sensitive security issue, this message is to request a PGP key for further communication. Please acknowledge receipt of this message by email to [email protected]

For further information about the Cisco Vendor Vulnerability Reporting and Disclosure Policy please refer to this document which also links to our public PGP key. https://tools.cisco.com/security/center/resources/vendor_vulnerability_policy.html Please CC [email protected] on all correspondence related to this issue.

Output structured data

Hi, I'm the author of https://github.com/nkh/P5-App-Asciio

A contributor ( THE contributor ;) ) uses Diagon and has been bugging me to try it, nice work, I was looking for something to replace PlantUml.

Then it hit me that we work on different parts of the documentation space which I would describe as:

.----------.               .------------.            .-----------------.
| raw data |-->transform-->| input data |-->Diagon-->| ASCII rendering |----.
'----------'               '------------'            '-----------------'    |
                    .-------------------------------------------------------'
                    |
                    v                                .---------------.
                 Asciio--------------------->Goat--->| SVG rendering |
                                                     '---------------'

The problem here is that the ASCII rendering from Diagon is just a block of codes and Asciio can only manipulate it as a block.

If Diagon was capable to output structured data describing what objects are placed were, then that input could be transformed in Asciio elements that can be manipulated before they are output as ASCII or passed to Goat/svgbob, ... to generate SVG.

So I'm seeing Diagon as some sort of Graphviz .

If you already have the layout information, could you generated a structured output?

WebAssembly usage on backend (Deno, Node.js)

Hello,

This project looks really great! I've noticed there are no builds for arm64 in releases (I'm using Debian 12 and installing with .deb file), so I've tried to create wrapper around webassembly (in Deno), which would work on every architecture, but, I can't find source code of diagon.js file, which I need to understand how webassembly bindings work here. Can someone help me understand how to get the source code of this file? Thanks in advance!

I tried to import diagon.js file directly, but it's not es module so it failed. Anyway, I would prefer to 'talk to' webassembly directly, unless it requires lots of effort.

Crash with invalid input

pawelp@pawelp-mb-13 fltk % echo "1/2=" | ../../../Diagon/build-osx/diagon Math
line 1:4 mismatched input '\n' expecting {STRING, '(', '{', '[', '+', '-', VARIABLE}
zsh: done                echo "1/2=" |
zsh: segmentation fault  ../../../Diagon/build-osx/diagon Math

Is there a way I could managed invalid input? I am writing gui plugin and I am not able to catch these kind of crashes.

Regards
Pawel

Make java an optional dependecy

Guess the title say it all. It would be fantastic, but not sure how deeply you depend on java, though. Anyhow, the tool is kind a nice.

Sequence: a way to make a visual difference between async and sync calls

as i wrote in issue #63 a way to quickly see if a sequence call is async or sync would be a great enhancement.

as an example solid lines would be sync, and for example dashed lines would be async.

as things are now i use '(as)' in the line message to denote the async calls but it clutters the view for such a simple thing as a dashed line would solve.

its a great tool so far.

Limes in Mathematical expression

Would it be possible to support limes in Mathematical expression? I was trying to write something like: lim_{n -> infinity} 1/n but there was error with symbol ">" and everything after "lim_{n -> infinity}".

In my opinion it should generate output similar to this:
1
lim --
n->∞ n

How to create Sequence with multi lines in command-line?

Read from file ok.

But make the command in my application, then call _popen, the command string like this "diagon Sequence -style=Unicode -- "Renderer -> Browser: BeginNavigation()" -- "Browser -> Network: URLRequest()" -- "Browser <- Network: URLResponse()" -- "Browser <- Network: URLResponse()" -- "Renderer <- Browser: CommitNavigation()" -- "Renderer -> Browser: DidCommitNavigation()"", cannot work?

How to make the command string?

leading spaces option

Hi. Your application is very fine and easy use syntax. It is very useful for me. I use Diagon in plain text documentation.
Would it be possible to add leading spaces, like indented, to the Math generator, like generator option? Or maybe as a general option? Thank you.

Allow more complicated composition of characters in sub and superscript

Hi me here once again.

I have another request, but as before feel free to ignore it if it is out of scope. I post the issues because I would really like to use the tool to create in-code equations and it can almost do everything I want 😄

As mentioned before, for scientific equations there can often be complicated both super and subscripts. As it is right now, the sub or super script seems to allow only sequences of letters or numbers and ends as soon as they are mixed or if a special character is added. This means e.g. that if I wanted to do what I in Latex would write as E_{2m} or I{_M'} the m and the ' disappears and breaks the equation. Would it be possible to add an apply-to-start-and-end like the {} in Latex, to make it possible to make these more elaborate sub and super scripts.

Regards Kenneth

Support "freeform" flowcharts

Couldn't come up with a better name, I would like to draw diagrams like this:

I there any possiblity to do this with diagon or could that be implemented? The diagram above is made with Monodraw, which does not have Linux support and. It would be great if Diagon could be used for this, I'm looking for a tool to create this kind of diagrams for docs and architectural overviews for software.

antlr.jar not found

I find this a wonderful project, thanks for making it.

When trying to package for NixOS I found that my build stuck at locating the antlr.jar:

Consolidate compiler generated dependencies of target antlr4_static
[ 92%] Built target antlr4_static
[ 92%] Generating GraphPlanarLexer.cpp, GraphPlanarParser.cpp, GraphPlanarLexer.h, GraphPlanarParser.h
[ 92%] Generating FlowchartLexer.cpp, FlowchartParser.cpp, FlowchartLexer.h, FlowchartParser.h
[ 92%] Generating MathLexer.cpp, MathParser.cpp, MathLexer.h, MathParser.h
[ 92%] Generating SequenceLexer.cpp, SequenceParser.cpp, SequenceLexer.h, SequenceParser.h
Error: Unable to access jarfile /nix/store/7g8306l1a9qxw7xswcdlbrm61v16wzi5-source/tools/antlr.jar

I'm pretty much a beginner coming to cmake or even nix, maybe you have a clue and can give a nudge here ?

This my default.nix for the build so far:

{ pkgs ? import <nixpkgs> {}, ... }:
pkgs.stdenv.mkDerivation {
  name = "Diagon";
  src = pkgs.lib.cleanSource (builtins.fetchTarball https://github.com/ArthurSonzogni/Diagon/tarball/master);
  nativeBuildInputs = with pkgs; [ cmake pkgconfig git cacert (jre_minimal.override { jdk = jdk11_headless; }) ant ];
  buildInputs = with pkgs; [ boost libuuid.dev icu ];
  propagatedBuildInputs = with pkgs; [ antlr ];
}

Also I'm getting

[100%] Built target antlr-populate
-- Building without demo. To enable demo build use: -DWITH_DEMO=True
-- Output libraries to /home/me/DiagonBuild/build/dist
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 162 100 162 0 0 2253 0 --:--:-- --:--:-- --:--:-- 2281
Warning: Failed to create the file antlr.jar: Permission denied
0 2040k 0 1005 0 0 3199 0 0:10:53 --:--:-- 0:10:53 3199
curl: (23) Failure writing output to destination

when running the eval cmake $cmakeFlags -Wno-dev -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON $src

Support on macOS (via Homebrew)

Great project! It would be really nice if we had support on macOS via Homebrew, allowing users to install Diagon via brew install diagon.

Is there anything that would prevent a build on OSX in principle? I tried to build it on OSX Big Sur 11.6 with Apple Clang 13, but no success with a first shot:

5/12] Building CXX object CMakeFiles/input_output_test.dir/src/input_output_test.cpp.o
FAILED: CMakeFiles/input_output_test.dir/src/input_output_test.cpp.o
ccache /usr/local/opt/llvm/bin/clang++  -I/tmp/Diagon/build/src -I/tmp/Diagon/src -isystem /usr/local/opt/llvm/include/c++/v1 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -Wall -Wno-sign-compare -Wno-attributes -std=gnu++17 -MD -MT CMakeFiles/input_output_test.dir/src/input_output_test.cpp.o -MF CMakeFiles/input_output_test.dir/src/input_output_test.cpp.o.d -o CMakeFiles/input_output_test.dir/src/input_output_test.cpp.o -c /tmp/Diagon/src/input_output_test.cpp
/tmp/Diagon/src/input_output_test.cpp:67:34: error: invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'const std::filesystem::directory_entry')
        std::cout << "  [PASS] " << test << std::endl;
        ~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
/usr/local/opt/llvm/include/c++/v1/cstddef:141:3: note: candidate function template not viable: no known conversion from 'basic_ostream<char, std::char_traits<char>>' to 'std::byte' for 1st argument
  operator<< (byte  __lhs, _Integer __shift) noexcept
  ^
/usr/local/opt/llvm/include/c++/v1/ostream:748:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'char' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
^
/usr/local/opt/llvm/include/c++/v1/ostream:781:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:788:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'signed char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:795:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:809:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const char *' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
^
/usr/local/opt/llvm/include/c++/v1/ostream:855:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:862:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const signed char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:870:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const unsigned char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1055:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const std::error_code' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
^
/usr/local/opt/llvm/include/c++/v1/ostream:741:1: note: candidate template ignored: deduced conflicting types for parameter '_CharT' ('char' vs. 'std::filesystem::directory_entry')
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
^
/usr/local/opt/llvm/include/c++/v1/__random/uniform_int_distribution.h:282:1: note: candidate template ignored: could not match 'uniform_int_distribution<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:802:1: note: candidate template ignored: could not match 'const _CharT *' against 'std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1038:1: note: candidate template ignored: could not match 'basic_string<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:1046:1: note: candidate template ignored: could not match 'basic_string_view<type-parameter-0-0, type-parameter-0-1>' against 'std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:1063:1: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1082:1: note: candidate template ignored: could not match 'bitset<_Size>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1030:11: note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied [with _Stream = std::ostream &, _Tp = std::filesystem::directory_entry]
_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
          ^
/usr/local/opt/llvm/include/c++/v1/ostream:1075:1: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-2, type-parameter-0-3>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:362:1: note: candidate template ignored: could not match '__iom_t8<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:482:1: note: candidate template ignored: could not match '__iom_t10<type-parameter-0-0>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:572:33: note: candidate template ignored: could not match '__quoted_output_proxy<type-parameter-0-0, type-parameter-0-2, type-parameter-0-1>' against 'const std::filesystem::directory_entry'
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
/usr/local/opt/llvm/include/c++/v1/iomanip:592:33: note: candidate template ignored: could not match '__quoted_proxy<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>' against 'const std::filesystem::directory_entry'
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
/usr/local/opt/llvm/include/c++/v1/ostream:188:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::ostream &(*)(std::ostream &)' for 1st argument
    basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:192:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'basic_ios<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> &(*)(basic_ios<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> &)' (aka 'basic_ios<char, std::char_traits<char>> &(*)(basic_ios<char, std::char_traits<char>> &)') for 1st argument
    basic_ostream& operator<<(basic_ios<char_type, traits_type>&
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:197:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::ios_base &(*)(std::ios_base &)' for 1st argument
    basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:200:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'bool' for 1st argument
    basic_ostream& operator<<(bool __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:201:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'short' for 1st argument
    basic_ostream& operator<<(short __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:202:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned short' for 1st argument
    basic_ostream& operator<<(unsigned short __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:203:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'int' for 1st argument
    basic_ostream& operator<<(int __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:204:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned int' for 1st argument
    basic_ostream& operator<<(unsigned int __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:205:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long' for 1st argument
    basic_ostream& operator<<(long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:206:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned long' for 1st argument
    basic_ostream& operator<<(unsigned long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:207:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long long' for 1st argument
    basic_ostream& operator<<(long long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:208:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned long long' for 1st argument
    basic_ostream& operator<<(unsigned long long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:209:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'float' for 1st argument
    basic_ostream& operator<<(float __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:210:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'double' for 1st argument
    basic_ostream& operator<<(double __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:211:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long double' for 1st argument
    basic_ostream& operator<<(long double __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:212:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const void *' for 1st argument; take the address of the argument with &
    basic_ostream& operator<<(const void* __p);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:213:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'basic_streambuf<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> *' (aka 'basic_streambuf<char, std::char_traits<char>> *') for 1st argument
    basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:216:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    basic_ostream& operator<<(nullptr_t)
                   ^
/tmp/Diagon/src/input_output_test.cpp:69:34: error: invalid operands to binary expression ('basic_ostream<char, std::char_traits<char>>' and 'const std::filesystem::directory_entry')
        std::cout << "  [FAIL] " << test << std::endl;
        ~~~~~~~~~~~~~~~~~~~~~~~~ ^  ~~~~
/usr/local/opt/llvm/include/c++/v1/cstddef:141:3: note: candidate function template not viable: no known conversion from 'basic_ostream<char, std::char_traits<char>>' to 'std::byte' for 1st argument
  operator<< (byte  __lhs, _Integer __shift) noexcept
  ^
/usr/local/opt/llvm/include/c++/v1/ostream:748:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'char' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, char __cn)
^
/usr/local/opt/llvm/include/c++/v1/ostream:781:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:788:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'signed char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, signed char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:795:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned char' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, unsigned char __c)
^
/usr/local/opt/llvm/include/c++/v1/ostream:809:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const char *' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const char* __strn)
^
/usr/local/opt/llvm/include/c++/v1/ostream:855:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:862:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const signed char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const signed char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:870:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const unsigned char *' for 2nd argument
operator<<(basic_ostream<char, _Traits>& __os, const unsigned char* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1055:1: note: candidate function template not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const std::error_code' for 2nd argument
operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __ec)
^
/usr/local/opt/llvm/include/c++/v1/ostream:741:1: note: candidate template ignored: deduced conflicting types for parameter '_CharT' ('char' vs. 'std::filesystem::directory_entry')
operator<<(basic_ostream<_CharT, _Traits>& __os, _CharT __c)
^
/usr/local/opt/llvm/include/c++/v1/__random/uniform_int_distribution.h:282:1: note: candidate template ignored: could not match 'uniform_int_distribution<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:802:1: note: candidate template ignored: could not match 'const _CharT *' against 'std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const _CharT* __str)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1038:1: note: candidate template ignored: could not match 'basic_string<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:1046:1: note: candidate template ignored: could not match 'basic_string_view<type-parameter-0-0, type-parameter-0-1>' against 'std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os,
^
/usr/local/opt/llvm/include/c++/v1/ostream:1063:1: note: candidate template ignored: could not match 'shared_ptr<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, shared_ptr<_Yp> const& __p)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1082:1: note: candidate template ignored: could not match 'bitset<_Size>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const bitset<_Size>& __x)
^
/usr/local/opt/llvm/include/c++/v1/ostream:1030:11: note: candidate template ignored: requirement 'integral_constant<bool, false>::value' was not satisfied [with _Stream = std::ostream &, _Tp = std::filesystem::directory_entry]
_Stream&& operator<<(_Stream&& __os, const _Tp& __x)
          ^
/usr/local/opt/llvm/include/c++/v1/ostream:1075:1: note: candidate template ignored: could not match 'unique_ptr<type-parameter-0-2, type-parameter-0-3>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, unique_ptr<_Yp, _Dp> const& __p)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:362:1: note: candidate template ignored: could not match '__iom_t8<type-parameter-0-2>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t8<_MoneyT>& __x)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:482:1: note: candidate template ignored: could not match '__iom_t10<type-parameter-0-0>' against 'const std::filesystem::directory_entry'
operator<<(basic_ostream<_CharT, _Traits>& __os, const __iom_t10<_CharT>& __x)
^
/usr/local/opt/llvm/include/c++/v1/iomanip:572:33: note: candidate template ignored: could not match '__quoted_output_proxy<type-parameter-0-0, type-parameter-0-2, type-parameter-0-1>' against 'const std::filesystem::directory_entry'
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
/usr/local/opt/llvm/include/c++/v1/iomanip:592:33: note: candidate template ignored: could not match '__quoted_proxy<type-parameter-0-0, type-parameter-0-1, type-parameter-0-2>' against 'const std::filesystem::directory_entry'
basic_ostream<_CharT, _Traits>& operator<<(
                                ^
/usr/local/opt/llvm/include/c++/v1/ostream:188:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::ostream &(*)(std::ostream &)' for 1st argument
    basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:192:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'basic_ios<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> &(*)(basic_ios<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> &)' (aka 'basic_ios<char, std::char_traits<char>> &(*)(basic_ios<char, std::char_traits<char>> &)') for 1st argument
    basic_ostream& operator<<(basic_ios<char_type, traits_type>&
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:197:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::ios_base &(*)(std::ios_base &)' for 1st argument
    basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:200:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'bool' for 1st argument
    basic_ostream& operator<<(bool __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:201:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'short' for 1st argument
    basic_ostream& operator<<(short __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:202:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned short' for 1st argument
    basic_ostream& operator<<(unsigned short __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:203:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'int' for 1st argument
    basic_ostream& operator<<(int __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:204:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned int' for 1st argument
    basic_ostream& operator<<(unsigned int __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:205:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long' for 1st argument
    basic_ostream& operator<<(long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:206:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned long' for 1st argument
    basic_ostream& operator<<(unsigned long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:207:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long long' for 1st argument
    basic_ostream& operator<<(long long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:208:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'unsigned long long' for 1st argument
    basic_ostream& operator<<(unsigned long long __n);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:209:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'float' for 1st argument
    basic_ostream& operator<<(float __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:210:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'double' for 1st argument
    basic_ostream& operator<<(double __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:211:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'long double' for 1st argument
    basic_ostream& operator<<(long double __f);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:212:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'const void *' for 1st argument; take the address of the argument with &
    basic_ostream& operator<<(const void* __p);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:213:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'basic_streambuf<std::basic_ostream<char>::char_type, std::basic_ostream<char>::traits_type> *' (aka 'basic_streambuf<char, std::char_traits<char>> *') for 1st argument
    basic_ostream& operator<<(basic_streambuf<char_type, traits_type>* __sb);
                   ^
/usr/local/opt/llvm/include/c++/v1/ostream:216:20: note: candidate function not viable: no known conversion from 'const std::filesystem::directory_entry' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
    basic_ostream& operator<<(nullptr_t)
                   ^
2 errors generated.
[6/12] Building CXX object src/translator/graph_planar/CMakeFiles/translator_graph_planar.dir/GraphPlanar.cpp.o
FAILED: src/translator/graph_planar/CMakeFiles/translator_graph_planar.dir/GraphPlanar.cpp.o
ccache /usr/local/opt/llvm/bin/clang++  -I/tmp/Diagon/build/src -I/tmp/Diagon/src -I/tmp/Diagon/build/_deps/antlr-src/runtime/Cpp/runtime/src -isystem /usr/local/opt/llvm/include/c++/v1 -O3 -DNDEBUG -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX11.3.sdk -Wno-attributes -Wall -Wno-sign-compare -std=gnu++17 -MD -MT src/translator/graph_planar/CMakeFiles/translator_graph_planar.dir/GraphPlanar.cpp.o -MF src/translator/graph_planar/CMakeFiles/translator_graph_planar.dir/GraphPlanar.cpp.o.d -o src/translator/graph_planar/CMakeFiles/translator_graph_planar.dir/GraphPlanar.cpp.o -c /tmp/Diagon/src/translator/graph_planar/GraphPlanar.cpp
/tmp/Diagon/src/translator/graph_planar/GraphPlanar.cpp:18:10: fatal error: 'boost/graph/adjacency_list.hpp' file not found
#include <boost/graph/adjacency_list.hpp>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
ninja: build

Horizontal DAG graph

I use Diagon for comments in my source code, so the vertical orientation is inconvenient.
Is it possible to have horizontal orientation?

horizontal:
┌─┐┌─┐
│a->b|
└─┘└─┘

vertical:
┌─┐
│a│
└┬┘
┌▽┐
│b│
└─┘

Missing uuid module (in antlr dependencies)

There is a problem with missing uuid module, which cannot be successfully found by pkg-config during antlr dependencies resolving.

The error log:

-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'uuid'
--   No package 'uuid' found

This can be fixed by installing uuid-dev package on Ubuntu (tested on Ubuntu 18.04.1 LTS, Xubuntu flavour actually), should also work on Debian.

For those who look only for code snippets:

sudo apt-get install uuid-dev

Can be marked as resolved.

I've added this issue mainly because grepping for uuid.h in antlr dependencies and reverse searching this file in using apt-file might not be obvious for everyone.

How to build?

Hi there, I'm not very proficient with C, just trying to typeset some nice math :)

I clone the repo on a Mac and ran cmake, then make and got the following output:

[  1%] Building CXX object CMakeFiles/diagon_base.dir/src/translator/Translator.cpp.o
In file included from /Users/dteiml/projects/Diagon/src/translator/Translator.cpp:5:
/Users/dteiml/projects/Diagon/src/translator/Translator.h:15:27: warning: defaulted function definitions are a C++11 extension [-Wc++11-extensions]
  virtual ~Translator() = default;
                          ^
/Users/dteiml/projects/Diagon/src/translator/Translator.h:34:61: warning: generalized initializer lists are a C++11 extension [-Wc++11-extensions]
  virtual std::vector<OptionDescription> Options() { return {}; }
                                                            ^~
/Users/dteiml/projects/Diagon/src/translator/Translator.h:34:61: error: non-aggregate type 'std::vector<OptionDescription>' cannot be initialized with an initializer list
  virtual std::vector<OptionDescription> Options() { return {}; }
                                                            ^~
/Users/dteiml/projects/Diagon/src/translator/Translator.h:40:52: warning: generalized initializer lists are a C++11 extension [-Wc++11-extensions]
  virtual std::vector<Example> Examples() { return {}; }
                                                   ^~
/Users/dteiml/projects/Diagon/src/translator/Translator.h:40:52: error: non-aggregate type 'std::vector<Example>' cannot be initialized with an initializer list
  virtual std::vector<Example> Examples() { return {}; }
                                                   ^~
3 warnings and 2 errors generated.
make[2]: *** [CMakeFiles/diagon_base.dir/src/translator/Translator.cpp.o] Error 1
make[1]: *** [CMakeFiles/diagon_base.dir/all] Error 2
make: *** [all] Error 2

I googled the errors and got here and then here, which together seemed to provide an answer.

Based on that, I tried running make CXXFLAGS='-std=c++11'. However, I got the same output. Any help, thanks!

I made vscode extension using Diagon API

Hi Arthur !
I found out that your tool could be really useful for us programmers. In fact, this tool will allow us to put better comments by adding diagrams, mathematical expressions and much more! I have compiled your API to webassembly and I created a javascript library wrapper that I published to npm. I was able to use that library in my vscode extension . I'll publish this extension soon in the vscode marketplace !
I hope you liked it!
Thank you for this tool !
screencast

I made a Vim plugin wrapping Diagon's API

Hi, thanks for this useful tool!

I am a Vim/Neovim user and I draw simple diagrams in markdown from time to time. When I met Diagon I wonder if I can integrate it into my workflow, so I made a Vim plugin named vim-diagon wrapping Diagon's API. It is pretty bare bone but it improves my workflow. You can give it a try if you want.

Thanks again!

Application crashes on too long input

App is not generating output for more than 16 000 characters long input. The crash occurs in tools: Tree, Mathematical expression, Graph - DAG, Graph - planar, Table, Frame. While trying to add any characters about that limit (to already inserted input) application crashes and user needs to refreash website. While trying to insert input longer than 16 000 characters (without anything added in input place before) app does not generate any output and crashes.
Sometimes it displays error message "Aborted(OOM)" and in such case it's good to know there is an error.
I think it would be nice to add how long input can be to README file and also make error messages in every tool.
aborted

Support self message for Sequence

image
As above, currently self message is not supported.
I think this is used pretty common.
Could you please consider adding this function?

New lines in Tree

Would it be possible to ignore additional new lines within one tree?
Like in this example:
parent
child1

child2

child1 and child2 are in the same tree but the output looks like:
parent
`-child1

`-child2

In my oponion empty lines between them should be ignored for better looking tree, like this:
parent
-child1
-child2

Integrate kgt?

What about integrating kgt into Diagon?
This would allow people to use kgt online & interactively.

I can totally see myself using it. For instance when implementing CSP in Chrome or just for fun.

I will take a look. I should be quite easy since this is C code. I just need to rewrite Makefile into a CMake file.

+CC: @katef FYI

missing build instructions

this is a phenomenal project. A few hints about compiling from source that might be useful:

On Debian / Ubuntu you will need boost (in addition to uuid-dev) otherwise the build fails:

sudo apt install libboost1.71-dev

then:

mkdir build && cd build 
cmake ..
make -j
sudo make install

Some grammar online demos not working

When trying https://arthursonzogni.com/Diagon/#Grammar and selecting ISO-EBNF-EBNF we get this error:

2:14: Syntax error: expected production rule separator

And when selecting WSN-WSN we get this error:

2:14: Syntax error

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.