diff options
Diffstat (limited to 'src/net/sourceforge/plantuml/command/CommandPragma.java')
-rw-r--r-- | src/net/sourceforge/plantuml/command/CommandPragma.java | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/src/net/sourceforge/plantuml/command/CommandPragma.java b/src/net/sourceforge/plantuml/command/CommandPragma.java index a430705..260772c 100644 --- a/src/net/sourceforge/plantuml/command/CommandPragma.java +++ b/src/net/sourceforge/plantuml/command/CommandPragma.java @@ -2,7 +2,7 @@ * PlantUML : a free UML diagram generator * ======================================================================== * - * (C) Copyright 2009-2017, Arnaud Roques + * (C) Copyright 2009-2020, Arnaud Roques * * Project Info: http://plantuml.com * @@ -35,31 +35,45 @@ */ package net.sourceforge.plantuml.command; -import java.util.List; - +import net.sourceforge.plantuml.LineLocation; import net.sourceforge.plantuml.StringUtils; import net.sourceforge.plantuml.UmlDiagram; +import net.sourceforge.plantuml.command.regex.IRegex; +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.dot.GraphvizUtils; -public class CommandPragma extends SingleLineCommand<UmlDiagram> { +public class CommandPragma extends SingleLineCommand2<UmlDiagram> { public CommandPragma() { - super("(?i)^!pragma[%s]+([A-Za-z_][A-Za-z_0-9]*)(?:[%s]+(.*))?$"); + super(getRegexConcat()); + } + + static IRegex getRegexConcat() { + return RegexConcat.build(CommandPragma.class.getName(), RegexLeaf.start(), // + new RegexLeaf("!pragma"), // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("NAME", "([A-Za-z_][A-Za-z_0-9]*)"), // + new RegexOptional( // + new RegexConcat( // + RegexLeaf.spaceOneOrMore(), // + new RegexLeaf("VALUE", "(.*)") // + )), RegexLeaf.end()); // } @Override - protected CommandExecutionResult executeArg(UmlDiagram system, List<String> arg) { - final String name = StringUtils.goLowerCase(arg.get(0)); - final String value = arg.get(1); + protected CommandExecutionResult executeArg(UmlDiagram system, LineLocation location, RegexResult arg) { + final String name = StringUtils.goLowerCase(arg.get("NAME", 0)); + final String value = arg.get("VALUE", 0); system.getPragma().define(name, value); if (name.equalsIgnoreCase("graphviz_dot") && value.equalsIgnoreCase("jdot")) { system.setUseJDot(true); } - // else if (name.equalsIgnoreCase("graphviz_dot") && OptionFlags.ALLOW_INCLUDE) { - // final String cmd = StringUtils.eventuallyRemoveStartingAndEndingDoubleQuote(value); - // if (cmd.toLowerCase().endsWith("dot") || cmd.toLowerCase().endsWith("dot.exe")) { - // system.setDotExecutable(cmd); - // } - // } + if (name.equalsIgnoreCase("graphviz_dot") && value.equalsIgnoreCase(GraphvizUtils.VIZJS)) { + system.getSkinParam().setUseVizJs(true); + } return CommandExecutionResult.ok(); } |