all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#62054: Problem with CSS font-family exported by htmlfontify
@ 2023-03-08 12:39 Kenta USAMI
  2023-03-16  7:46 ` Eli Zaretskii
  0 siblings, 1 reply; 2+ messages in thread
From: Kenta USAMI @ 2023-03-08 12:39 UTC (permalink / raw)
  To: 62054


[-- Attachment #1.1: Type: text/plain, Size: 1198 bytes --]

First, I use a font called "Migu 2M" in Emacs.

When I run 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.

The attached patch file fixes that issue. Thank you for reading.

[-- Attachment #1.2: Type: text/html, Size: 1670 bytes --]

[-- Attachment #2: 0001-Fix-hfy-family.patch --]
[-- Type: application/octet-stream, Size: 935 bytes --]

From 13f08caeae3fc562b92c9229a80e5656c1d7dd65 Mon Sep 17 00:00:00 2001
From: USAMI Kenta <tadsan@zonu.me>
Date: Wed, 8 Mar 2023 21:13:37 +0900
Subject: [PATCH] Fix hfy-family

---
 lisp/htmlfontify.el | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lisp/htmlfontify.el b/lisp/htmlfontify.el
index 1ab33cc641..f0e38242e4 100644
--- a/lisp/htmlfontify.el
+++ b/lisp/htmlfontify.el
@@ -757,7 +757,9 @@ hfy-triplet
                             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")
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#62054: Problem with CSS font-family exported by htmlfontify
  2023-03-08 12:39 bug#62054: Problem with CSS font-family exported by htmlfontify Kenta USAMI
@ 2023-03-16  7:46 ` Eli Zaretskii
  0 siblings, 0 replies; 2+ messages in thread
From: Eli Zaretskii @ 2023-03-16  7:46 UTC (permalink / raw)
  To: Kenta USAMI; +Cc: 62054-done

> From: Kenta USAMI <zonuexe@zonu.me>
> Date: Wed, 8 Mar 2023 21:39:26 +0900
> 
> First, I use a font called "Migu 2M" in Emacs.
> 
> When I run 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.
> 
> The attached patch file fixes that issue. Thank you for reading.

Thanks, I installed this on the emacs-29 branch, and I'm closing this
bug.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-16  7:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-08 12:39 bug#62054: Problem with CSS font-family exported by htmlfontify Kenta USAMI
2023-03-16  7:46 ` Eli Zaretskii

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.