From: Thomas Morley <thomasmorley65@gmail.com>
Date: Tue, 15 Mar 2016 23:10:20 +0000 (+0100)
Subject: Issue 4809 Keep "\""-signs for graphviz
X-Git-Tag: release/2.19.40-1~11^2~5
X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=6992c0bd640070493aeedcdb9f95be7c206e47d6;p=lilypond.git

Issue 4809 Keep "\""-signs for graphviz

Transform them to "\\\""
---

diff --git a/ly/graphviz-init.ly b/ly/graphviz-init.ly
index 470faffa6a..96f45ded93 100644
--- a/ly/graphviz-init.ly
+++ b/ly/graphviz-init.ly
@@ -2,6 +2,8 @@
 
 #(use-modules (scm graphviz))
 
+#(use-modules (ice-9 regex))
+
 #(define last-grob-action '())
 
 #(define sym-blacklist '())
@@ -55,9 +57,13 @@
 
 #(define (grob-mod grob file line func prop val)
   (let* ((val-str (truncate-value val))
-         (label (format #f "~a\\n~a:~a\\n~a <- ~a" (grob::name grob) file line prop val-str)))
+         (label (format #f "~a\\n~a:~a\\n~a <- ~a" (grob::name grob) file line prop val-str))
+         ;; to keep escaped "\"" we need to transform it to "\\\""
+         ;; otherwise the final pdf-creation will break
+         (escaped-label
+           (regexp-substitute/global #f "\"" label 'pre "\\\"" 'post)))
    (if (relevant? grob file line prop)
-       (grob-event-node grob label file))))
+       (grob-event-node grob escaped-label file))))
 
 #(define (grob-cache grob prop callback value)
   (let* ((val-str (truncate-value value))