aboutsummaryrefslogtreecommitdiff
path: root/dump.scm
diff options
context:
space:
mode:
authorArun Isaac2021-12-11 18:54:09 +0530
committerArun Isaac2021-12-11 18:56:13 +0530
commita8d8bda3ea03b2f4d1cc99c66e8d2defaffc2758 (patch)
treef7e3fd6b5e4eb33f087c3db130e545ff471317ed /dump.scm
parent14381f313b1ca871f3516931f477b232b35b3545 (diff)
downloadgn-transform-databases-a8d8bda3ea03b2f4d1cc99c66e8d2defaffc2758.tar.gz
Fix HTML string handling in dot output.
* dump.scm (replace-substrings): New function. (graph->dot): Fix HTML string handling.
Diffstat (limited to 'dump.scm')
-rwxr-xr-xdump.scm22
1 files changed, 17 insertions, 5 deletions
diff --git a/dump.scm b/dump.scm
index cf8439b..43f3ea6 100755
--- a/dump.scm
+++ b/dump.scm
@@ -94,6 +94,15 @@
str
substrings))
+(define (replace-substrings str replacement-alist)
+ "Replace substrings in STR according to REPLACEMENT-ALIST, an
+association list mapping substrings to their replacements."
+ (fold (match-lambda*
+ (((substring . replacement) str)
+ (string-replace-substring str substring replacement)))
+ str
+ replacement-alist))
+
(define (string->identifier prefix str)
"Convert STR to a turtle identifier after replacing illegal
characters with an underscore and prefixing with gn:PREFIX."
@@ -546,15 +555,18 @@ case-insensitive."
(else
(format #f "~a GiB" (round-quotient bytes (expt 1024 3))))))
-;; This wrapper function is necessary to work around a bug in (ccwl
-;; graphviz) whereby backslashes in node labels are escaped and
-;; printed as \\.
+;; This wrapper function is necessary to work around bugs in (ccwl
+;; graphviz) whereby backslashes in node labels are escaped as \\, and
+;; HTML strings are escaped incorrectly.
(define (graph->dot graph)
(put-string (current-output-port)
- (string-replace-substring
+ (replace-substrings
(call-with-output-string
(cut (@@ (ccwl graphviz) graph->dot) graph <>))
- "\\\\" "\\")))
+ '(("\\\\" . "\\")
+ ("\"<<" . "<<")
+ (">>\"" . ">>")
+ ("\\\"" . "\"")))))
(define (trigrams str)
"Return all trigrams in STR."