Browse code

Fix slash quoting (issue 61).

José Fonseca authored on 01/09/2011 08:41:49
Showing 1 changed files

  • xdot.py index 7f3a25e..a3dcb4d 100755
... ...
@@ -475,7 +475,7 @@ class XDotAttrParser:
475 475
 
476 476
     def __init__(self, parser, buf):
477 477
         self.parser = parser
478
-        self.buf = self.unescape(buf)
478
+        self.buf = buf
479 479
         self.pos = 0
480 480
         
481 481
         self.pen = Pen()
... ...
@@ -484,11 +484,6 @@ class XDotAttrParser:
484 484
     def __nonzero__(self):
485 485
         return self.pos < len(self.buf)
486 486
 
487
-    def unescape(self, buf):
488
-        buf = buf.replace('\\"', '"')
489
-        buf = buf.replace('\\n', '\n')
490
-        return buf
491
-
492 487
     def read_code(self):
493 488
         pos = self.buf.find(" ", self.pos)
494 489
         res = self.buf[self.pos:pos]
... ...
@@ -957,10 +952,11 @@ class DotLexer(Lexer):
957 952
             text = text.replace('\\\r', '')
958 953
             text = text.replace('\\\n', '')
959 954
             
960
-            text = text.replace('\\r', '\r')
961
-            text = text.replace('\\n', '\n')
962
-            text = text.replace('\\t', '\t')
963
-            text = text.replace('\\', '')
955
+            # quotes
956
+            text = text.replace('\\"', '"')
957
+
958
+            # layout engines recognize other escape codes (many non-standard)
959
+            # but we don't translate them here
964 960
 
965 961
             type = ID
966 962