From 6c1414b915f927fc6b83a192a9ff8345da64be82 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 29 Sep 2026 10:20:10 +0100 Subject: [PATCH 1/2] Resolve Issue 75 --- gap/dot.gi | 21 ++++++++++++++++++++- tst/dot.tst | 12 +++++++++++- tst/examples/structs.tst | 20 ++++++++++---------- 3 files changed, 41 insertions(+), 12 deletions(-) diff --git a/gap/dot.gi b/gap/dot.gi index 384dd07..d266e0a 100644 --- a/gap/dot.gi +++ b/gap/dot.gi @@ -256,10 +256,29 @@ InstallMethod(GraphvizSetAttr, "for a graphviz node or edge, object, and object", [IsGraphvizNodeOrEdge, IsObject, IsObject], function(x, name, value) - GraphvizAttrs(x)[String(name)] := String(value); + name := String(name); + value := String(value); + NormalizeWhitespace(name); + NormalizeWhitespace(value); + GraphvizAttrs(x)[name] := value; return x; end); +InstallMethod(GraphvizSetAttr, +"for a graphviz node or edge, and string", +[IsGraphvizNodeOrEdge, IsString], +function(x, str) + local attr; + + attr := SplitString(str, "="); + if Length(attr) <> 2 then + ErrorFormatted("expected a string of the form \"attribute_name=value\", ", + "but the input string {} does not contain \"=\"", str); + fi; + + return GraphvizSetAttr(x, attr[1], attr[2]); +end); + InstallMethod(GraphvizSetAttr, "for a graphviz object with subobjects, object, and object", [IsGraphvizGraphDigraphOrContext, IsObject, IsObject], diff --git a/tst/dot.tst b/tst/dot.tst index 6fa19fe..fa57de9 100644 --- a/tst/dot.tst +++ b/tst/dot.tst @@ -8,7 +8,7 @@ ############################################################################# ## -#@local a, b, color, e, g, gv, label, n, shape, G, D +#@local a, b, color, e, g, gv, label, n, shape, G, D, innode, f gap> START_TEST("graphviz package: dot.tst"); gap> LoadPackage("GraphvizForGAP", false);; @@ -229,5 +229,15 @@ gap> GraphvizNodes(g); AsString(g); rec( a := , b := ) "//dot\ndigraph unexpected {\n\ta\n\tb\n\ta -> b\n\tb -> a\n}\n" +# Issue 75 +gap> f := GraphvizDigraph("blah"); + +gap> GraphvizSetAttr(f, "rankdir", "min"); + +gap> innode := GraphvizAddNode(f, "in"); + +gap> GraphvizSetAttr(innode, "shape= \"none\""); + + # gap> STOP_TEST("graphviz package: dot.tst", 0); diff --git a/tst/examples/structs.tst b/tst/examples/structs.tst index 2d6492d..3429ad6 100644 --- a/tst/examples/structs.tst +++ b/tst/examples/structs.tst @@ -65,16 +65,16 @@ gap> GraphvizAddEdge(s, "struct1:f2", "struct3:here"); # gap> AsString(s); "//dot\ndigraph structs {\n\tnode [shape=\"plaintext\"] \n\tstruct1 [label=<\n\nleft\nmiddleright\n\n>]\n\tstru\ -ct2 [label=<\n\none\n\n\n
two
>]\n\tstruct3 [label=<\n\n<\ -TD ROWSPAN=\"3\">hello
world\nb\ng\nh\n\n\nc\nd\ne\n\n\nf\n\n>]\n\tstruct1:f1\n\tstruct2:f0\n\tstruct1:f1 -> struct2:f0\n\tstruct1:f2\n\ts\ -truct3:here\n\tstruct1:f2 -> struct3:here\n}\n" +ABLE BORDER=\"0\" CELLBORDER=\"1\" CELLSPACING=\"0\"> left middleright >]\n\tstruct2 [\ +label=<
one two
>]\n\tstruct3 [label=< <\ +TD ROWSPAN=\"3\">h
hello
world
b g
c d e
f
>]\n\tstruct1:f1\n\tstru\ +ct2:f0\n\tstruct1:f1 -> struct2:f0\n\tstruct1:f2\n\tstruct3:here\n\tstruct1:f2\ + -> struct3:here\n}\n" # gap> STOP_TEST("graphviz package: examples/structs.tst"); From 29e83fec4a9b282ff03f117a04fd8d2e0f12bd86 Mon Sep 17 00:00:00 2001 From: James Mitchell Date: Tue, 29 Sep 2026 10:34:59 +0100 Subject: [PATCH 2/2] Increase line length to 100 --- .gaplint.yml | 1 + PackageInfo.g | 2 +- gap/dot.gd | 3 ++- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.gaplint.yml b/.gaplint.yml index a6e81f9..649e05c 100644 --- a/.gaplint.yml +++ b/.gaplint.yml @@ -1,2 +1,3 @@ disable: - align-assignments +columns: 100 diff --git a/PackageInfo.g b/PackageInfo.g index 8c67a2a..e380876 100644 --- a/PackageInfo.g +++ b/PackageInfo.g @@ -45,7 +45,7 @@ Persons := [ Status := "dev", SourceRepository := rec(Type := "git", - URL := "https://github.com/gap-packages/GraphvizForGAP"), + URL := "https://github.com/gap-packages/GraphvizForGAP"), IssueTrackerURL := Concatenation(~.SourceRepository.URL, "/issues"), PackageWWWHome := "https://gap-packages.github.io/GraphvizForGAP/", diff --git a/gap/dot.gd b/gap/dot.gd index c09bee8..0f0e43a 100644 --- a/gap/dot.gd +++ b/gap/dot.gd @@ -403,7 +403,8 @@ DeclareOperation("GraphvizSetName", #! @Returns a &GAPGraphviz; node object #! @Description Adds a node to the graph. #! If a node with the same name is already present the operation fails. -#! What constitute a valid node name is found at https://graphviz.org/doc/info/lang.html +#! What constitute a valid node name is found at +#! https://graphviz.org/doc/info/lang.html #! @BeginExampleSession #! @EndExampleSession DeclareOperation("GraphvizAddNode",