summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorUSAMI Kenta <tadsan@zonu.me>2023-03-08 21:13:37 +0900
committerEli Zaretskii <eliz@gnu.org>2023-03-16 09:41:56 +0200
commit028f11027384b6fb6807ea4057073e3be4003e9e (patch)
tree8cdaacebcfd75881d2396be64f5dd7c04ef31b6e
parent4cb8a850b08cc77abe979a7e245bde48206f79a5 (diff)
downloademacs-028f11027384b6fb6807ea4057073e3be4003e9e.tar.gz
emacs-028f11027384b6fb6807ea4057073e3be4003e9e.tar.bz2
emacs-028f11027384b6fb6807ea4057073e3be4003e9e.zip
Fix quoting of font-family in 'hfy-family'
Running "M-x htmlfontify-buffer" in one buffer, the exported HTML contains lines like: body, pre { text-decoration: none; font-family: Migu 2M; font-stretch: normal; font-weight: 500; font-style: normal; color: #ffffff; background: #000000; font-size: 15pt; } Standards-compliant web browsers should ignore this font-family. MDN Web Docs says: https://developer.mozilla.org/en-US/docs/Web/CSS/font-family Valid family names Font family names must either be given quoted as strings, or unquoted as a sequence of one or more identifiers. This means that punctuation characters and digits at the start of each token must be escaped in unquoted font family names. It is a good practice to quote font family names that contain white space, digits, or punctuation characters other than hyphens. An unquoted font-family is valid as long as it doesn't start with a digit, but MDN Web Docs also says: The following example is technically valid but is not recommended: font-family: Gill Sans Extrabold, sans-serif; So it makes sense to quote all font-family. * lisp/htmlfontify.el (hfy-family): Quote 'font-family'. (Bug#62054)
-rw-r--r--lisp/htmlfontify.el4
1 files changed, 3 insertions, 1 deletions
diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el
index 1ab33cc6411..f0e38242e48 100644
--- a/lisp/htmlfontify.el
+++ b/lisp/htmlfontify.el
@@ -757,7 +757,9 @@ may happen."
255))
'(0 1 2))))))
-(defun hfy-family (family) (list (cons "font-family" family)))
+(defun hfy-family (family)
+ (list (cons "font-family"
+ (format "\"%s\"" (string-replace "\"" "\\\\\"" family)))))
(defun hfy-bgcol (color) (list (cons "background" (hfy-triplet color))))
(defun hfy-color (color) (list (cons "color" (hfy-triplet color))))
(define-obsolete-function-alias 'hfy-colour #'hfy-color "27.1")