qmuntal / stateless

Go library for creating finite state machines
BSD 2-Clause "Simplified" License
898 stars 47 forks source link

Invalid DOT graph generated when methods are used as actions #37

Closed cezarsa closed 2 years ago

cezarsa commented 2 years ago

When methods are used as actions calling .ToGraph() generates an invalid DOT file with incorrect string quoting for the method name.

It's easy to reproduce the issue with the code in https://go.dev/play/p/SVJBbhx760k, the DOT output contains the following line which has too many double quotes:

initial [label="initial|entry / "method-fm""];

Trying to call dot with this output causes the following error:

$ dot -Tsvg ./a.dot
Error: ./a.dot: syntax error in line 6 near '-'

I can try following up with a PR latter but I'm afraid I'm not well-versed in DOT format and all the possible quoting rules.

qmuntal commented 2 years ago

Getting the quotes right is tricky. Fixed in #38.