varkor / quiver

A modern commutative diagram editor for the web.
https://q.uiver.app
MIT License
2.37k stars 78 forks source link

Export to ASCII #211

Open stschaef opened 4 months ago

stschaef commented 4 months ago

It's lovely to output actual tikz drawings from the editor, but I was wondering if it would be easy/possible to export to ASCII (or possibly Unicode)

My lab does a lot of category theory proofs in agda, and being able to include well-formatted commutative diagrams as comments is often very helpful. However, these are drawn by hand by us and often look messy. A principled method to generate ASCII diagrams would be used by at least 5 of us (and hopefully other people in the community!)

This is a very low priority issue and I've thought of homebaking something myself but have never found the time. I'd love to hear any thoughts on how you think this could leverage existing code

Thanks

varkor commented 4 months ago

If there is an algorithm to convert commutative diagrams to ASCII, I would be willing to integrate it in quiver. That is, integration of new export methods is easy. However, an algorithm that produces accurate ASCII seems difficult in all but the simplest cases. It's certainly not something I have time to investigate myself, but if someone else came up with a solution, I would be willing to review it.

user202729 commented 1 month ago

Currently there is tex2mail, but...

  1. It's implemented in Perl.
  2. It in my opinion goes a bit too far in the conversion. E.g.

    [~]$ tex2mail <<< 'x^2'
     2
    x 
    
    [~]$ tex2mail <<< '\sqrt{x^2}'
     +--+
     | 2
    \|x 

    I don't think it's necessary to move the 2 to the line above.

Looking at https://tex.stackexchange.com/questions/6431/options-for-converting-latex-to-plain-text there doesn't seem to be too many options.

Depends on your editor a saner option (*) might be to install preview-latex or something and somehow make it preview commutative diagram too. (Theoretically possible as long as the editor isn't terminal-only)

(*): More setup cost in the beginning (edit everything in order to support embedding image in code), but seems to me like the "morally correct" solution to the problem.