aboutsummaryrefslogtreecommitdiff
path: root/ccwl
diff options
context:
space:
mode:
authorArun Isaac2021-12-13 17:41:19 +0530
committerArun Isaac2021-12-13 18:06:04 +0530
commit64ed9fb4581b290c6c64152e577ee166ff1d4dd7 (patch)
tree5ac4f4b6e1c07844d79a64bc0d878f27b44f7086 /ccwl
parentb42c56555a06cdd75070fcef64587f67f09f91a9 (diff)
downloadccwl-64ed9fb4581b290c6c64152e577ee166ff1d4dd7.tar.gz
ccwl-64ed9fb4581b290c6c64152e577ee166ff1d4dd7.tar.lz
ccwl-64ed9fb4581b290c6c64152e577ee166ff1d4dd7.zip
ccwl: Escape only the double quote character in graphviz output.
* ccwl/graphviz.scm: Import (ice-9 string-fun). (serialize): When quoting strings, escape only the double quote character. * tests/graphviz.scm ("do not escape backslashes"): New test case.
Diffstat (limited to 'ccwl')
-rw-r--r--ccwl/graphviz.scm9
1 files changed, 5 insertions, 4 deletions
diff --git a/ccwl/graphviz.scm b/ccwl/graphviz.scm
index fbef971..a3f4036 100644
--- a/ccwl/graphviz.scm
+++ b/ccwl/graphviz.scm
@@ -29,6 +29,7 @@
#:use-module (srfi srfi-26)
#:use-module (srfi srfi-28)
#:use-module (ice-9 match)
+ #:use-module (ice-9 string-fun)
#:use-module (ccwl ccwl)
#:use-module (ccwl utils)
#:export (workflow->dot))
@@ -129,15 +130,15 @@ symbol, a string, or a <html-string> object."
;; Surround HTML strings in <>, and don't escape.
((html-string? object)
(format "<~a>" str))
- ;; Don't escape safe strings.
+ ;; Don't quote safe strings.
((string-every (char-set-union (char-set-intersection char-set:letter+digit
char-set:ascii)
(char-set #\_))
str)
str)
- ;; Escape strings with unsafe characters.
- (else (call-with-output-string
- (cut write str <>))))))
+ ;; Quote strings with unsafe characters.
+ (else
+ (format "\"~a\"" (string-replace-substring str "\"" "\\\""))))))
(define* (graph->dot graph #:optional (port (current-output-port)) (level 0))
"Render GRAPH, a <graph> object, in the graphviz dot syntax to