emacs-diffs
[Top][All Lists]
Advanced

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

emacs-29 028f1102738: Fix quoting of font-family in 'hfy-family'


From: Eli Zaretskii
Subject: emacs-29 028f1102738: Fix quoting of font-family in 'hfy-family'
Date: Thu, 16 Mar 2023 03:46:15 -0400 (EDT)

branch: emacs-29
commit 028f11027384b6fb6807ea4057073e3be4003e9e
Author: USAMI Kenta <tadsan@zonu.me>
Commit: Eli Zaretskii <eliz@gnu.org>

    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)
---
 lisp/htmlfontify.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

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")



reply via email to

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