From: USAMI Kenta Date: Wed, 8 Mar 2023 12:13:37 +0000 (+0900) Subject: Fix quoting of font-family in 'hfy-family' X-Git-Tag: emacs-29.0.90~170 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=028f11027384b6fb6807ea4057073e3be4003e9e;p=emacs.git 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) --- 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")