Mike Samuel
Mike Samuel

Reputation: 120486

How do you escape strings when generating graphviz?

Any ideas how to escape arbitrary strings so that they're usable as labels in Graphviz .dot files?

I'm trying to dump a graph representation to xdot to aid with debugging some complicated transformation.

So I followed https://graphviz.org/docs/attr-types/escString/ to try to figure out how to escape quoted strings used as node and edge labels.

Basically, just escaping \ and " to \\ and \" respectively.

But escaping \ seems to result in errors in xdot that actually point elsewhere.

$ (echo 'digraph { N[label="(\\s)"]; }') | xdot -
error: unknown xdot opcode ')'

Upvotes: 0

Views: 654

Answers (1)

sroush
sroush

Reputation: 6763

dot is happy with the escaped string, it seems to be an xdot.py bug.
dot produced:
enter image description here

Upvotes: 1

Related Questions