diff options
author | Arun Isaac | 2021-12-11 18:54:09 +0530 |
---|---|---|
committer | Arun Isaac | 2021-12-11 18:56:13 +0530 |
commit | a8d8bda3ea03b2f4d1cc99c66e8d2defaffc2758 (patch) | |
tree | f7e3fd6b5e4eb33f087c3db130e545ff471317ed | |
parent | 14381f313b1ca871f3516931f477b232b35b3545 (diff) | |
download | gn-transform-databases-a8d8bda3ea03b2f4d1cc99c66e8d2defaffc2758.tar.gz |
Fix HTML string handling in dot output.
* dump.scm (replace-substrings): New function.
(graph->dot): Fix HTML string handling.
-rwxr-xr-x | dump.scm | 22 |
1 files changed, 17 insertions, 5 deletions
@@ -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." |