Skip to content

Commit

Permalink
fix: math two-dimensional matrices and add test
Browse files Browse the repository at this point in the history
Report of The-Lum/ASCIIMathTeXImg@6f3bb01d
That fixes plantuml#1706

Regards,
Th.
  • Loading branch information
The-Lum committed Mar 10, 2024
1 parent 1188a05 commit f82f1a9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/net/sourceforge/plantuml/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -905,8 +905,8 @@ private String[] AMTparseExpr(String str, boolean rightbracket) {
subarr = new ArrayList<String>(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,
Expand Down
3 changes: 3 additions & 0 deletions test/net/sourceforge/plantuml/math/MathTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f82f1a9

Please sign in to comment.