Skip to content

Commit

Permalink
🚧 prepare multilines support
Browse files Browse the repository at this point in the history
  • Loading branch information
arnaudroques committed Dec 16, 2024
1 parent 6ef3f1c commit d7b8735
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/net/sourceforge/plantuml/jaws/JawsFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public class JawsFlags {

public static final boolean USE_BLOCK_E1_IN_NEWLINE_FUNCTION = true;
public static final boolean USE_CommandSkinParamJaws = true;
public static final boolean PARSE_NEW_MULTILINE_TRIPLE_EXCLAMATION_MARKS = false;
public static final boolean PARSE_NEW_MULTILINE_TRIPLE_MARKS = false;

//public static final boolean OLD_DISPLAY_HACK = true;

Expand Down
2 changes: 2 additions & 0 deletions src/net/sourceforge/plantuml/klimt/creole/Display.java
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,8 @@ else if (sub.startsWith("</math>") || sub.startsWith("</latex>") || sub.startsWi
naturalHorizontalAlignment = HorizontalAlignment.LEFT;
result.add(current.toString());
current.setLength(0);
} else if (c == Jaws.BLOCK_E1_INVISIBLE_QUOTE) {
// No thing to do, just ignore this character
} else if (c == Jaws.BLOCK_E1_NEWLINE_RIGHT_ALIGN) {
naturalHorizontalAlignment = HorizontalAlignment.RIGHT;
result.add(current.toString());
Expand Down
17 changes: 15 additions & 2 deletions src/net/sourceforge/plantuml/text/StringLocated.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.sourceforge.plantuml.StringUtils;
import net.sourceforge.plantuml.jaws.Jaws;
Expand Down Expand Up @@ -69,8 +71,8 @@ final public class StringLocated {
//}

public List<StringLocated> expandsJawsForPreprocessor() {
if (JawsFlags.PARSE_NEW_MULTILINE_TRIPLE_EXCLAMATION_MARKS) {
final int x = s.indexOf("!!!");
if (JawsFlags.PARSE_NEW_MULTILINE_TRIPLE_MARKS) {
final int x = searchMultilineTripleSeparators();
if (x == -1)
return Arrays.asList(this);
final String s1 = s.substring(0, x);
Expand All @@ -81,6 +83,17 @@ public List<StringLocated> expandsJawsForPreprocessor() {
return Arrays.asList(this);
}

private static final Pattern TRIPLE_PATTERN = Pattern.compile("!!!|'''|\"\"\"");

private int searchMultilineTripleSeparators() {
final Matcher matcher = TRIPLE_PATTERN.matcher(s);

if (matcher.find())
return matcher.start();

return -1;
}

public List<StringLocated> expandsJaws5() {
final List<StringLocated> copy = new ArrayList<>();
for (String s : expandsJaws3())
Expand Down

0 comments on commit d7b8735

Please sign in to comment.