jbn / IPlantUML

A Python package which defines a PlantUML cell magic for IPython.
MIT License
95 stars 28 forks source link

plantweb --format auto file.txt fails to format AsciiMath / Latex #23

Open mood-indigo opened 1 year ago

mood-indigo commented 1 year ago

I copied this example from Math in PlantUML

@startuml
Bob -> Alice : Can you solve: <math>ax^2+bx+c=0</math>
Alice --> Bob: <math>x = (-b+-sqrt(b^2-4ac))/(2a)</math>
@enduml

to p.uml

In a JupyterLab notebook, I have this code cell

%%bash
plantweb --format auto p.uml

The generated p.svg does not shows beautiful math, it still shows the AsciiMath code:

p

But when I changed the code cell to

%%bash
plantweb --format png p.uml

the generated p.png looks beautifully formatted. p

The --format auto and --format svg do not correctly format the AsciiMath and jLatexMath code.

mood-indigo commented 1 year ago

I'm not sure whether the bug is in iplantuml or plantweb. I did an experiment based on Python API, I use this code cell

from plantweb.render import render

CONTENT = """
Bob -> Alice : Can you solve: <math>ax^2+bx+c=0</math>
Alice --> Bob: <math>x = (-b+-sqrt(b^2-4ac))/(2a)</math>
"""

output = render(
    CONTENT,
    engine='plantuml',
    format='svg',
    cacheopts={
        'use_cache': False
    }
)

with open("alice+bob.svg", "wb") as f:
    f.write(output[0])

The AsciiMath code was not correctly formatted. But when I changed the format to png, it turned out correct.

This shows that the bug is in plantweb.