@@ -88,7 +88,7 @@ public static TextParserV1.NodeList recursiveParsing(String input, TextParserV1.
8888 var text = new ArrayList <TextNode >();
8989
9090 Matcher matcher = STARTING_PATTERN .matcher (input );
91- Matcher matcherEnd = endAt != null ? Pattern .compile (endAt ).matcher (input ) : null ;
91+ Matcher matcherEnd = endAt != null ? Pattern .compile ("(" + endAt + ")|(</>)" ).matcher (input ) : null ;
9292 int currentPos = 0 ;
9393 int offset = 0 ;
9494 boolean hasEndTag = endAt != null && matcherEnd .find ();
@@ -112,7 +112,7 @@ public static TextParserV1.NodeList recursiveParsing(String input, TextParserV1.
112112 currentEnd = matcher .start ();
113113 if (currentPos < currentEnd ) {
114114 String restOfText = restoreOriginalEscaping (input .substring (currentPos , currentEnd ));
115- if (restOfText .length () != 0 ) {
115+ if (! restOfText .isEmpty () ) {
116116 text .add (new LiteralNode (restOfText ));
117117 }
118118 }
@@ -121,7 +121,7 @@ public static TextParserV1.NodeList recursiveParsing(String input, TextParserV1.
121121 } else {
122122 String betweenText = input .substring (currentPos , matcher .start ());
123123
124- if (betweenText .length () != 0 ) {
124+ if (! betweenText .isEmpty () ) {
125125 text .add (new LiteralNode (restoreOriginalEscaping (betweenText )));
126126 }
127127 currentPos = matcher .end ();
@@ -139,7 +139,7 @@ public static TextParserV1.NodeList recursiveParsing(String input, TextParserV1.
139139 if (handler != null ) {
140140 String betweenText = input .substring (currentPos , matcher .start ());
141141
142- if (betweenText .length () != 0 ) {
142+ if (! betweenText .isEmpty () ) {
143143 text .add (new LiteralNode (restoreOriginalEscaping (betweenText )));
144144
145145 }
@@ -175,13 +175,13 @@ public static TextParserV1.NodeList recursiveParsing(String input, TextParserV1.
175175
176176 if (currentPos < currentEnd ) {
177177 String restOfText = restoreOriginalEscaping (input .substring (currentPos , currentEnd ));
178- if (restOfText .length () != 0 ) {
178+ if (! restOfText .isEmpty () ) {
179179 text .add (new LiteralNode (restOfText ));
180180 }
181181 }
182182
183183 if (hasEndTag ) {
184- currentEnd += endAt .length ();
184+ currentEnd += matcherEnd . group () .length ();
185185 } else {
186186 currentEnd = input .length ();
187187 }
@@ -212,7 +212,7 @@ public static String convertToString(Text text) {
212212 }
213213 }
214214
215- if (stringList .size () > 0 ) {
215+ if (! stringList .isEmpty () ) {
216216 stringList .add (0 , "" );
217217 }
218218
0 commit comments