1
0
mirror of https://github.com/octoleo/plantuml.git synced 2024-11-22 13:05:09 +00:00

Merge pull request #979 from gwilherm/evol/link-in-ref

Evol/link in ref
This commit is contained in:
PlantUML 2022-04-01 23:54:27 +02:00 committed by GitHub
commit c88448d3da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 13 deletions

View File

@ -45,6 +45,10 @@ import net.sourceforge.plantuml.UrlMode;
import net.sourceforge.plantuml.command.BlocLines;
import net.sourceforge.plantuml.command.CommandExecutionResult;
import net.sourceforge.plantuml.command.CommandMultilines;
import net.sourceforge.plantuml.command.regex.RegexConcat;
import net.sourceforge.plantuml.command.regex.RegexLeaf;
import net.sourceforge.plantuml.command.regex.RegexOptional;
import net.sourceforge.plantuml.command.regex.RegexResult;
import net.sourceforge.plantuml.cucadiagram.Display;
import net.sourceforge.plantuml.sequencediagram.Participant;
import net.sourceforge.plantuml.sequencediagram.Reference;
@ -55,24 +59,43 @@ import net.sourceforge.plantuml.ugraphic.color.NoSuchColorException;
public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<SequenceDiagram> {
public CommandReferenceMultilinesOverSeveral() {
super("^ref(#\\w+)?[%s]+over[%s]+((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)[%s]*(#\\w+)?$");
super(getConcat().getPattern());
}
private static RegexConcat getConcat() {
return RegexConcat.build(CommandReferenceMultilinesOverSeveral.class.getName(),
RegexLeaf.start(), //
new RegexLeaf("ref"), //
new RegexLeaf("REF", "(#\\w+)?"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("over"), //
RegexLeaf.spaceOneOrMore(), //
new RegexLeaf("PARTS", "((?:[%pLN_.@]+|[%g][^%g]+[%g])(?:[%s]*,[%s]*(?:[%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
RegexLeaf.end());
}
@Override
public String getPatternEnd() {
return "^end[%s]?(ref)?$";
}
public CommandExecutionResult execute(final SequenceDiagram diagram, BlocLines lines) throws NoSuchColorException {
final List<String> line0 = StringUtils.getSplit(getStartingPattern(),
lines.getFirst().getTrimmed().getString());
final String s1 = line0.get(0);
String firstLine = lines.getFirst().getTrimmed().getString();
RegexResult arg = getConcat().matcher(firstLine);
if (arg == null) {
return CommandExecutionResult.error("Cannot parse line " + firstLine);
}
String s1 = arg.get("REF", 0);
final HColor backColorElement = s1 == null ? null
: diagram.getSkinParam().getIHtmlColorSet().getColor(diagram.getSkinParam().getThemeStyle(), s1);
// final HtmlColor backColorGeneral =
// HtmlColorSetSimple.instance().getColorIfValid(line0.get(1));
final List<String> participants = StringUtils.splitComma(line0.get(1));
final List<String> participants = StringUtils.splitComma(arg.get("PARTS", 0));
final List<Participant> p = new ArrayList<>();
for (String s : participants) {
p.add(diagram.getOrCreateParticipant(StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(s)));
@ -82,13 +105,11 @@ public class CommandReferenceMultilinesOverSeveral extends CommandMultilines<Seq
lines = lines.removeEmptyColumns();
Display strings = lines.toDisplay();
String url = arg.get("URL", 0);
final UrlBuilder b = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
Url u = null;
if (strings.size() > 0) {
final UrlBuilder urlBuilder = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
u = urlBuilder.getUrl(strings.get(0).toString());
}
if (u != null) {
strings = strings.subList(1, strings.size());
if (url != null) {
u = b.getUrl(url);
}
final HColor backColorGeneral = null;

View File

@ -72,9 +72,10 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
new RegexLeaf("PARTS",
"(([%pLN_.@]+|[%g][^%g]+[%g])([%s]*,[%s]*([%pLN_.@]+|[%g][^%g]+[%g]))*)"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
RegexLeaf.spaceZeroOrMore(), //
new RegexLeaf(":"), //
RegexLeaf.spaceZeroOrMore(), //
new RegexOptional(new RegexLeaf("URL", "(\\[\\[.*?\\]\\])")), //
new RegexLeaf("TEXT", "(.*)"), RegexLeaf.end());
}
@ -98,7 +99,7 @@ public class CommandReferenceOverSeveral extends SingleLineCommand2<SequenceDiag
final Display strings = Display.getWithNewlines(text);
final UrlBuilder b = new UrlBuilder(null, UrlMode.STRICT);
final UrlBuilder b = new UrlBuilder(diagram.getSkinParam().getValue("topurl"), UrlMode.STRICT);
Url u = null;
if (url != null) {
u = b.getUrl(url);