Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 39 LaTeX math support #54

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dakusui
Copy link

@dakusui dakusui commented Aug 24, 2019

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

  • This enhancement introduces a new semantics to a certain character in a text and it means potentially hurts a compatibility. And for this product, we need keep the backward compatibility because there are quite a few users who use ditaa as automatic document generation backend. Thus, this feature must be disabled by default.
  • .svg support is discussed separately in Issue-44.

Tasks

  • Implement tests
  • Fix a bug where * is rendered as a bullet point (or a connector?) even if it is placed inside $ and $.
  • Remove pom.xml
    • Backport chages made in pom.xml to project.clj
  • Provide a documentation.
  • Implement an option to enable this feature. This must be disabled by default.
  • Make tests work under leiningen.

This was referenced Aug 24, 2019
:junit ["test/java"]
:junit-formatter :plain
:junit-results-dir "target/test-results"
:profiles {:dev {:dependencies [[junit/junit "4.12"] [com.github.dakusui/thincrest "3.6.0"]]
:java-source-paths ["test/java"]}})
Copy link
Author

@dakusui dakusui Aug 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change was intended to run JUnit based tests with lein test.

@@ -227,7 +227,7 @@
@Test public void testFindBoundariesExpandingFromUOutside() throws FileNotFoundException, IOException {
TextGrid grid;
grid = new TextGrid();
grid.loadFrom("tests/text/simple_U01.txt");
grid.loadFrom("test-resources/text/simple_U01.txt");

Copy link
Author

@dakusui dakusui Aug 24, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After introducing lein-junit, which executes JUnit based tests under test/java directory, I realized existing tests are not passing since we do not have resources under tests directory but in test-resources directory.
These changes will make those tests work again.

@dakusui
Copy link
Author

dakusui commented Oct 4, 2019

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

@torbsorb
Copy link

torbsorb commented Aug 9, 2021

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

@dakusui
Copy link
Author

dakusui commented Aug 9, 2021

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

@dakusui
Copy link
Author

dakusui commented Aug 9, 2021

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. : f2e613a?diff=unified&w=1
(Please note that my IDE formatted the file. If you don't prefer it, please let me know.)

@dakusui
Copy link
Author

dakusui commented Aug 9, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants