Skip to content

Commit

Permalink
✨ add newline command for formatting
Browse files Browse the repository at this point in the history
Add `newline` command for formatting: in order to add a new line between multiple formulas
Transfoms `newline` (AsciiMath) on `\\` (TeX).

Ref. :
- https://www.overleaf.com/learn/latex/Line_breaks_and_blank_spaces
- https://en.wikipedia.org/wiki/Newline

Request from:
- plantuml/plantuml#1824
  • Loading branch information
The-Lum committed Jun 15, 2024
1 parent 9e38a7d commit e7d2864
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions app/src/main/java/math/ASCIIMathTeXImg.java
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,9 @@ public boolean hasFlag(Flag flagName) {
new Tuple("mathtt" , "mstyle", "mathtt" , null , Ttype.UNARY ), //
new Tuple("fr" , "mstyle", "fr" , "mathfrak", Ttype.UNARY , Flag.NOTEXCOPY), //
new Tuple("mathfrak", "mstyle", "mathfrak", null , Ttype.UNARY ), //

// newline for formatting: in order to add a new line between multiple formulas
new Tuple("newline", "mo", "newline", "\\\\", Ttype.CONST, Flag.VAL, Flag.NOTEXCOPY), //
} //
));

Expand Down
4 changes: 4 additions & 0 deletions app/src/test/java/math/ASCIIMathTeXImgUnitTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -493,6 +493,10 @@ class ASCIIMathTeXImgUnitTest {
" f''' , {f}''' ",
" uArr , \\Uparrow ",
" dArr , \\Downarrow ",
" newline , \\\\ ",
" a newline b , {a}\\\\{b} ",
" anewlineb , {a}\\\\{b} ",
" a^2newlinea^3 , {a}^{{2}}\\\\{a}^{{3}} ",
})
void mathUnitTest(String input, String expected) {
final String res = cut.getTeX(input);
Expand Down
7 changes: 7 additions & 0 deletions app/src/test/java/math/TestUnitTestGen.java
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,13 @@ static void initAll() {
// Arrow (PR 138)
"uArr",
"dArr",

// Newline (see plantuml/plantuml#1824)
"newline",
"a newline b",
"anewlineb",
"a^2newlinea^3",

})
void test(String input) {
String res = cut.getTeX(input);
Expand Down

0 comments on commit e7d2864

Please sign in to comment.