emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master 1ad56d0: Fix up svg text encoding


From: Lars Ingebrigtsen
Subject: [Emacs-diffs] master 1ad56d0: Fix up svg text encoding
Date: Thu, 26 Oct 2017 15:49:03 -0400 (EDT)

branch: master
commit 1ad56d0a6bdd07c722a3c161096a16f70d1cbb35
Author: Lars Ingebrigtsen <address@hidden>
Commit: Lars Ingebrigtsen <address@hidden>

    Fix up svg text encoding
    
    * lisp/svg.el (svg--encode-text): The SVG driver doesn't like
    it if we use &apos; for apostrophe, so use our own encoding
    function instead of relying on the xml one.
---
 lisp/svg.el | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/lisp/svg.el b/lisp/svg.el
index 42619ed..ae7f1c5 100644
--- a/lisp/svg.el
+++ b/lisp/svg.el
@@ -161,9 +161,15 @@ otherwise.  IMAGE-TYPE should be a MIME image type, like
 
 (defun svg--encode-text (text)
   ;; Apparently the SVG renderer needs to have all non-ASCII
-  ;; characters encoded.
+  ;; characters encoded, and only certain special characters.
   (with-temp-buffer
-    (insert (xml-escape-string text))
+    (insert text)
+    (dolist (substitution '(("&" . "&amp;")
+                           ("<" . "&lt;")
+                           (">" . "&gt;")))
+      (goto-char (point-min))
+      (while (search-forward (car substitution) nil t)
+       (replace-match (cdr substitution) t t nil)))
     (goto-char (point-min))
     (while (not (eobp))
       (let ((char (following-char)))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]