1
0
mirror of https://git.savannah.gnu.org/git/emacs.git synced 2024-12-23 10:34:07 +00:00

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)
This commit is contained in:
USAMI Kenta 2023-03-08 21:13:37 +09:00 committed by Eli Zaretskii
parent 4cb8a850b0
commit 028f110273

View File

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