From f82f1a9a76b138168f7ad4f8f9015a570def285d Mon Sep 17 00:00:00 2001 From: The-Lum <86879521+The-Lum@users.noreply.github.com> Date: Sun, 10 Mar 2024 17:09:12 +0000 Subject: [PATCH] fix: math two-dimensional matrices and add test Report of https://github.com/The-Lum/ASCIIMathTeXImg/commit/6f3bb01d That fixes #1706 Regards, Th. --- src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java | 4 ++-- test/net/sourceforge/plantuml/math/MathTest.java | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java b/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java index 7a23f266783..d4d32969b61 100644 --- a/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java +++ b/src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java @@ -905,8 +905,8 @@ private String[] AMTparseExpr(String str, boolean rightbracket) { subarr = new ArrayList(Arrays.asList( newFrag.substring(pos.get(i) + 8, subpos.get(pos.get(i)).get(1)))); for (int j = 2; j < subpos.get(pos.get(i)).size(); j++) { - subarr.add(newFrag.substring(subpos.get(i).get(j - 1) + 1, - subpos.get(i).get(j))); + subarr.add(newFrag.substring(subpos.get(pos.get(i)).get(j - 1) + 1, + subpos.get(pos.get(i)).get(j))); } subarr.add(newFrag.substring( subpos.get(pos.get(i)).get(subpos.get(pos.get(i)).size() - 1) + 1, diff --git a/test/net/sourceforge/plantuml/math/MathTest.java b/test/net/sourceforge/plantuml/math/MathTest.java index d649d9c77f4..391ff41d612 100644 --- a/test/net/sourceforge/plantuml/math/MathTest.java +++ b/test/net/sourceforge/plantuml/math/MathTest.java @@ -17,6 +17,9 @@ class MathTest { " '[[a,b],[c,d]]', {\\left[\\begin{matrix}{a}&{b}\\\\{c}&{d}\\end{matrix}\\right]} ", " color(red)(x), {\\textcolor{red}{{x}}} ", " color(red)(t)=color(blue)(x), {\\textcolor{red}{{t}}}={\\textcolor{blue}{{x}}} ", + " f, {f} ", + " f_g, {{f}_{{g}}} ", + " '[[1,2,3],[4,5,6]]', {\\left[\\begin{matrix}{1}&{2}&{3}\\\\{4}&{5}&{6}\\end{matrix}\\right]} ", }) public void testMath(String input, String expected) { final String res = new ASCIIMathTeXImg().getTeX(input);