diff options
| -rw-r--r-- | lisp/net/shr.el | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lisp/net/shr.el b/lisp/net/shr.el index 81c3fb4aa52..1dff129b9dc 100644 --- a/lisp/net/shr.el +++ b/lisp/net/shr.el | |||
| @@ -1180,8 +1180,24 @@ Return a string with image data." | |||
| 1180 | ;; so glitches may occur during this transformation. | 1180 | ;; so glitches may occur during this transformation. |
| 1181 | (shr-dom-to-xml | 1181 | (shr-dom-to-xml |
| 1182 | (libxml-parse-xml-region (point) (point-max))))) | 1182 | (libxml-parse-xml-region (point) (point-max))))) |
| 1183 | ;; SVG images often do not have a specified foreground/background | ||
| 1184 | ;; color, so wrap them in styles. | ||
| 1185 | (when (eq content-type 'image/svg+xml) | ||
| 1186 | (setq data (svg--wrap-svg data))) | ||
| 1183 | (list data content-type))) | 1187 | (list data content-type))) |
| 1184 | 1188 | ||
| 1189 | (defun svg--wrap-svg (data) | ||
| 1190 | "Add a default foreground colour to SVG images." | ||
| 1191 | (with-temp-buffer | ||
| 1192 | (insert "<svg xmlns:xlink=\"http://www.w3.org/1999/xlink\" " | ||
| 1193 | "xmlns:xi=\"http://www.w3.org/2001/XInclude\" " | ||
| 1194 | "style=\"color: " | ||
| 1195 | (face-foreground 'default) ";\">" | ||
| 1196 | "<xi:include href=\"data:image/svg+xml;base64," | ||
| 1197 | (base64-encode-string data t) | ||
| 1198 | "\"></xi:include></svg>") | ||
| 1199 | (buffer-string))) | ||
| 1200 | |||
| 1185 | (defun shr-image-displayer (content-function) | 1201 | (defun shr-image-displayer (content-function) |
| 1186 | "Return a function to display an image. | 1202 | "Return a function to display an image. |
| 1187 | CONTENT-FUNCTION is a function to retrieve an image for a cid url that | 1203 | CONTENT-FUNCTION is a function to retrieve an image for a cid url that |