From d19a711a4455f4c7bf2ca87874132d3a97957a0b Mon Sep 17 00:00:00 2001 From: Jethro Kuan Date: Tue, 7 Jul 2020 13:07:10 +0800 Subject: [PATCH] (fix): fix escaping of backslashes in graph generation (#897) Fixes #884 --- org-roam-graph.el | 4 +++- org-roam-macs.el | 7 +++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/org-roam-graph.el b/org-roam-graph.el index 1727eb7..581333b 100644 --- a/org-roam-graph.el +++ b/org-roam-graph.el @@ -198,8 +198,10 @@ into a digraph." (`truncate (s-truncate org-roam-graph-max-title-length title)) (`wrap (s-word-wrap org-roam-graph-max-title-length title)) (_ title))) + (shortened-title (org-roam-string-quote shortened-title)) + (title (org-roam-string-quote title)) (node-properties - `(("label" . ,(s-replace "\"" "\\\"" shortened-title)) + `(("label" . ,shortened-title) ("URL" . ,(concat "org-protocol://roam-file?file=" (url-hexify-string file))) ("tooltip" . ,(xml-escape-string title))))) (insert diff --git a/org-roam-macs.el b/org-roam-macs.el index 74e9ff1..3522951 100644 --- a/org-roam-macs.el +++ b/org-roam-macs.el @@ -33,6 +33,7 @@ ;; ;;; Code: ;;;; Library Requires +(require 'dash) (defvar org-roam-verbose) @@ -68,6 +69,12 @@ to look. (when org-roam-verbose (apply #'message `(,(concat "(org-roam) " format-string) ,@args)))) +(defun org-roam-string-quote (str) + "Quote STR." + (->> str + (s-replace "\\" "\\\\") + (s-replace "\"" "\\\""))) + (provide 'org-roam-macs) ;;; org-roam-macs.el ends here