tabatkins / railroad-diagrams

:steam_locomotive: A small JS+SVG library for drawing railroad syntax diagrams, like on JSON.org. Now with a Python port!
MIT License
1.66k stars 153 forks source link

Python port problem? #69

Closed JohnCC330 closed 5 years ago

JohnCC330 commented 5 years ago

Rendering an SVG image generated by the Python port of railroad-diagrams, using librsvg causes this error:

gi.repository.GLib.Error: rsvg-error-quark: Error domain 1 code 9 on line 32 column 158 of data: xmlParseCharRef: invalid xmlChar value 0
 (0)

The file, at this point, contains:

     370  3d 22 32 30 22 3e 3c 2f  72 65 63 74 3e 3c 74 65  ="20"></rect><te
     380  78 74 20 78 3d 22 37 34  2e 32 35 22 20 79 3d 22  xt x="74.25" y="
     390  33 35 22 3e 26 23 39 31  2d 39 26 23 39 33 3c 2f  35">&#91-9&#93</                                   
     3a0  74 65 78 74 3e 3c 2f 67  3e 3c 70 61 74 68 20 64  text></g><path d                                   

or, in pain text: <text x="74.25" y="35">&#91-9&#93</text> which I suspect is missing the ';' after the entities (at least I suspect the entity syntax is the same as HTML's).

railroads.py, on line 22: ..., lambda c: "&#{0}".format(ord(c.group(0))), unicode(text)) seems to lack the ';' (I had to remove the initial characters of the line to avoid Markdown issues)

No expert in SVG - less in parsing. Am I correct here?

railroad.svg.txt

tabatkins commented 5 years ago

Fixed in https://github.com/tabatkins/railroad-diagrams/pull/71