Closed ouss1002 closed 2 months ago
Hello @ouss1002,
Here is an example (without exception!) on v1.2024.4beta6:
@startmath
((f), (g), (e), (h), (Lef), (Leg), (Lee), (Leh), (Lef_(n+1)), (Leg_(n+1)), (Lee_(n+1)), (Leh_(n+1)), (fi), (gi), (ei), (hi), (Lecos), (Lesin), (Lecos(x)), (Lesin(x)), ((Lecos)(x)), ((Lesin)(x)))
@endmath
Regards, Th.
Thank you for your response @The-Lum !
the primary condition of occurrence is that the formula needs to end with the function name's string. In your case, you have wrapped the expression inside parentheses.
For example, here is an instance where it doesn't work:
@startmath
f_n + g_n
@endmath
Whereas this one does work (using uppercase F and G):
@startmath
F_n + G_n
@endmath
To add more context, our teams use this functionality to write mathematical notation along with documentation.
A hypothetical example might go something like this:
@startmath
"The system can take advantage of the terms " f_n " and " f_(n+1) " to calculate the distance between the corresponding moving objects"
@endmath
Simply putting these terms at the end of the formula, throws the exception:
@startmath
"In order to calculate the distance between the corresponding moving objects, the system can take advantage of the terms " f_n " and " f_(n+1)
@endmath
providing any trailing characters/string (as long as it doesn't involve a function's name) will render it correctly:
@startmath
"In order to calculate the distance between the corresponding moving objects, the system can take advantage of the terms " f_n " and " f_(n+1) * a
@endmath
We can achieve the same outcome by using uppercase f & g instead:
@startmath
"In order to calculate the distance between the corresponding moving objects, the system can take advantage of the terms " F_n " and " F_(n+1)
@endmath
Hi @ouss1002,
Thanks a lot for all those precisions.
FYI: in order to improve (and test) the ASCIIMathTeXImg
, I just created this repo.:
[FYI @arnaudroques ]
Describe the bug I've encountered a bug related to the rendering of equations, specifically when using custom names for variables and functions. Under certain conditions, naming a function with specific trailing characters (e.g., "Reg") triggers an Exception:
java.lang.StringIndexOutOfBoundsException: String index out of range: 0
. This appears to be due to the texsymbol string variable atnet.sourceforge.plantuml.math.ASCIIMathTeXImg.AMTparseSexpr(ASCIIMathTeXImg.java:635)
being empty but still invoking .charAt(0).To Reproduce 1- Use a custom function name with a trailing character/string that is considered a function by Plantuml (e.g., 'g' in "Reg", 'f' in "Ref"). 2- Wrap it inside of a
@startmath ... @endmath
block 3- Render the equation.Expected behavior The equation renders correctly, regardless of the custom names used for functions or variables.
Actual behavior An IndexOutOfBoundsException is thrown, and the rendering is buggy/faulty for these formulae
Screenshots Here are the results with their corresponding formula code: Notice how the problem only appears when the letters f and g are in the end (even when there are some underscore reductions to be undergone). This exception is being raised every time the formula ends with a name of a standard function
['cos', 'sin', 'f', 'g', etc.]
Desktop:
Additional context The equations used to render correctly back in the version V1.2021.7 where the javascript engine used to be the one that renders the equations,. This is a regression as noted on the PlantUML website regarding potential regressions post-migration into Java in V1.2021.8
Plantuml version : 1.2024.3