stathissideris / ditaa

ditaa is a small command-line utility that can convert diagrams drawn using ascii art ('drawings' that contain characters that resemble lines like | / - ), into proper bitmap graphics.
GNU Lesser General Public License v3.0
924 stars 87 forks source link

Issue 39 LaTeX math support #54

Open dakusui opened 4 years ago

dakusui commented 4 years ago

This is a pull request that offers an implementation of Issue-#39 (LaTeX math mode support)

README

Usage and syntax

Command line

(snip)

 -e,--encoding <ENCODING>       The encoding of the input file.
 -h,--html                      In this case the input is an HTML file.
                                The contents of the <pre
                                class="textdiagram"> tags are rendered as
                                diagrams and saved in the images directory
                                and a new HTML file is produced with the
                                appropriate <img> tags.
    --help                      Prints usage help.
-L,--latex-math                 Enable LaTeX math mode.

(snip)

Syntax

(snip)

LaTeX mode.

If you place LaTeX formulae inside 2 $s, it will be rendered using jlatexmath. That is, if you have a following input files.


$Box_1$                    $Box^2$
+---------------------+    +------+   /---------\
|$\sum_{i=0}^{n}x^i$  |    |$cBLU$|   |         |
|                     +--->|cRED  +-=-+cGRE$C_k$|
|{io}                 |    |cXYZ  |   |{o}      |
+----------+----------+    +---+--+   \---------/
           |                   |
           |                   :
           |                   V
           |           +-------------------+
           +---------->*$A_i$ hello $B^i$  |
                       |              +----+
                       |              |c8FA|
                       +--------------+----+

$|Set| = o-*-Freunde-*-nicht=*=diese-=-*- * töne$

o Quick brown fox jumps over
* a lazy dog.

$Q_u^i$, $C_k$, $B_r^{own}$, $F_{ox}$ jumps

over a lazy $d\cdot\frac{o}{g}$.

$\forall x \in X, \quad \exists y \leq \epsilon$

$\sin A \cos B =$

    $ \frac{1}{2}\left[ \sin(A-B)+\sin(A+B) \right]$

$\frac{d}{dx}\left( \int_{0}^{x} f(u)\,du\right)=f(x).$

 $v \sim \mathcal{N} (m,\sigma^2)$

This will be rendered as follows.

art-latexmath-1

Limitations

This feature is only available when you are generating .png files.

Discussions

dakusui commented 4 years ago

@stathissideris , I believe this pull request is ready to merge. Please feel free to ask me if anything unclear.

torbsorb commented 2 years ago

Hi, I would very much welcome a merge of this PR!

dakusui commented 2 years ago

Seems like we need to resolve the conflict. Let me take a look.

dakusui commented 2 years ago

I resolved the conflict by moving the modification made by Toni Dietze Flupp@users.noreply.github.com in SVGBuilder.java to DiagramText.java. The change is found here. : https://github.com/stathissideris/ditaa/pull/54/commits/f2e613af11fd339614ccfacf8673c07b0cb06817?diff=unified&w=1 (Please note that my IDE formatted the file. If you don't prefer it, please let me know.)

dakusui commented 2 years ago

I could figure out a way to remove unnecessary changes introduced by my IDE. I think the PR is now ready for merge. In case you find anything, please let me know.