Skip to content

Commit

Permalink
Add workaround for #218
Browse files Browse the repository at this point in the history
  • Loading branch information
mdaines committed Oct 25, 2023
1 parent 68b1126 commit ee6897c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
4 changes: 4 additions & 0 deletions packages/viz/src/module/viz.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ Agraph_t *viz_read_one_graph(char *string) {
Agraph_t *graph = NULL;
Agraph_t *other_graph = NULL;

// Workaround for #218. Set the global default node label.

agattr(NULL, AGNODE, "label", "\\N");

// Reset errors

agseterrf(viz_errorf);
Expand Down
23 changes: 22 additions & 1 deletion packages/viz/test/render.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ stop
status: "success",
output: "graph {\n\tgraph [_background=123,\n\t\tbb=\"0,0,0,0\"\n\t];\n\tnode [label=\"\\N\"];\n}\n",
errors: [
{ level: "warning", message: "Could not parse \"_background\" attribute in graph %1" },
{ level: "warning", message: "Could not parse \"_background\" attribute in graph %3" },
{ level: "warning", message: " \"123\"" }
]
});
Expand All @@ -308,5 +308,26 @@ stop
]
});
});

it("the graph is read with the default node label set", function() {
const result = viz.render("graph { a; b[label=test] }");

assert.deepStrictEqual(result, {
status: "success",
output: `graph {
graph [bb="0,0,126,36"];
node [label="\\N"];
a [height=0.5,
pos="27,18",
width=0.75];
b [height=0.5,
label=test,
pos="99,18",
width=0.75];
}
`,
errors: []
});
});
});
});

0 comments on commit ee6897c

Please sign in to comment.