From c0d329e6d88b753935b2c55fe86af75247be3c06 Mon Sep 17 00:00:00 2001 From: James Shubin Date: Sat, 27 Apr 2019 16:12:41 -0400 Subject: [PATCH] pgraph: Quote graphviz strings properly If strings include quotes, this previously didn't work. --- pgraph/graphviz.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pgraph/graphviz.go b/pgraph/graphviz.go index 759b3de0..9c7f9227 100644 --- a/pgraph/graphviz.go +++ b/pgraph/graphviz.go @@ -46,14 +46,14 @@ func (g *Graph) Graphviz() (out string) { //out += "\tnode [shape=box];\n" str := "" for i := range g.Adjacency() { // reverse paths - out += fmt.Sprintf("\t\"%s\" [label=\"%s\"];\n", i, i) + out += fmt.Sprintf("\t%s [label=%s];\n", strconv.Quote(i.String()), strconv.Quote(i.String())) for j := range g.Adjacency()[i] { k := g.Adjacency()[i][j] // use str for clearer output ordering //if fmtBoldFn(k) { // TODO: add this sort of formatting // str += fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\",style=bold];\n", i, j, k) //} else { - str += fmt.Sprintf("\t\"%s\" -> \"%s\" [label=\"%s\"];\n", i, j, k) + str += fmt.Sprintf("\t%s -> %s [label=%s];\n", strconv.Quote(i.String()), strconv.Quote(j.String()), strconv.Quote(k.String())) //} } }