unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / Atom feed
* [website]: Fix rendering of entities.
@ 2020-09-09 21:35 Ricardo Wurmus
  2020-09-12 22:06 ` pelzflorian (Florian Pelz)
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2020-09-09 21:35 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 357 bytes --]

Hi Guix,

this page looks wrong: https://guix.gnu.org/packages/mpc-1.1.0/

The non-breaking space is rendered as “GNU<*ENTITY*>nbspMPC”.  The
attached patch processes the SHTML to remove *ENTITY* nodes, replacing
the “nbsp” entity with an actual non-breaking space; other entities are
silently converted to a single space.

-- 
Ricardo


[-- Attachment #2: 0001-website-Render-non-breaking-space-correctly.patch --]
[-- Type: text/x-patch, Size: 2124 bytes --]

From 7745f78abe8ba03cfc3de7655b7c5d766f5ad5b6 Mon Sep 17 00:00:00 2001
From: Ricardo Wurmus <rekado@elephly.net>
Date: Wed, 9 Sep 2020 23:32:28 +0200
Subject: [PATCH] website: Render non-breaking space correctly.

* website/apps/packages/utils.scm (texinfo->shtml): Replace *ENTITY*
node with a non-breaking space for the nbsp entity, or a space in case
of unknown entities.
---
 website/apps/packages/utils.scm | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index fb9d3cf..f13bec7 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix web site
 ;;; Copyright © 2017 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2017 Eric Bavier <bavier@member.fsf.org>
+;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
 ;;;
 ;;; Initially written by sirgazil
 ;;; who waives all copyright interest on this file.
@@ -32,6 +33,7 @@
   #:use-module (guix download)
   #:use-module (srfi srfi-1)
   #:use-module (srfi srfi-26)
+  #:use-module (sxml transform)
   #:use-module (texinfo)
   #:use-module (texinfo html)
   #:use-module (ice-9 match)
@@ -74,7 +76,17 @@
   ;; 'texi-fragment->stexi' uses 'call-with-input-string', so make sure
   ;; those string ports are Unicode-capable.
   (with-fluids ((%default-port-encoding "UTF-8"))
-    (stexi->shtml (texi-fragment->stexi texi))))
+    (let ((shtml (stexi->shtml (texi-fragment->stexi texi))))
+      (pre-post-order shtml
+                      `((*ENTITY*
+                         . ,(lambda (tag entity)
+                              (match entity
+                                ("nbsp" (string #\xa0))
+                                (_ " "))))
+                        (*default*
+                         . ,(lambda args args))
+                        (*text*
+                         . ,(lambda (_ txt) txt)))))))
 
 (define (package-description-shtml package)
   "Return a SXML representation of PACKAGE description field with HTML
-- 
2.28.0


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

* Re: [website]: Fix rendering of entities.
  2020-09-09 21:35 [website]: Fix rendering of entities Ricardo Wurmus
@ 2020-09-12 22:06 ` pelzflorian (Florian Pelz)
  2020-09-13  9:48   ` Ricardo Wurmus
  0 siblings, 1 reply; 4+ messages in thread
From: pelzflorian (Florian Pelz) @ 2020-09-12 22:06 UTC (permalink / raw)
  To: Ricardo Wurmus; +Cc: guix-devel

On Wed, Sep 09, 2020 at 11:35:06PM +0200, Ricardo Wurmus wrote:
> Hi Guix,
> 
> this page looks wrong: https://guix.gnu.org/packages/mpc-1.1.0/
> 
> The non-breaking space is rendered as “GNU<*ENTITY*>nbspMPC”.  The
> attached patch processes the SHTML to remove *ENTITY* nodes, replacing
> the “nbsp” entity with an actual non-breaking space; other entities are
> silently converted to a single space.
> […]
> +                              (match entity
> +                                ("nbsp" (string #\xa0))
> +                                (_ " "))))

Nice find.  LGTM as far as I can tell, except it would be nice if the ... / … in
<http://guix.gnu.org/de/packages/guile-hashing-1.2.0/> were not rendered as
a space.

Before:

The (hashing <*ENTITY*>hellip) modules implement cryptographic hash functions in pure R6RS Scheme: CRC, HMAC, MD5, SHA-1, and SHA-2 (SHA-256, SHA-512).

(or in SHTML
(div (p "The " (code "(hashing " (*ENTITY* "hellip") ")") " modules implement …"

After:

The (hashing ) modules implement cryptographic hash functions in pure R6RS Scheme: CRC, HMAC, MD5, SHA-1, and SHA-2 (SHA-256, SHA-512).


Regards,
Florian


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

* Re: [website]: Fix rendering of entities.
  2020-09-12 22:06 ` pelzflorian (Florian Pelz)
@ 2020-09-13  9:48   ` Ricardo Wurmus
  2020-09-13 21:52     ` Ricardo Wurmus
  0 siblings, 1 reply; 4+ messages in thread
From: Ricardo Wurmus @ 2020-09-13  9:48 UTC (permalink / raw)
  To: pelzflorian (Florian Pelz); +Cc: guix-devel


pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> writes:

> On Wed, Sep 09, 2020 at 11:35:06PM +0200, Ricardo Wurmus wrote:
>> Hi Guix,
>> 
>> this page looks wrong: https://guix.gnu.org/packages/mpc-1.1.0/
>> 
>> The non-breaking space is rendered as “GNU<*ENTITY*>nbspMPC”.  The
>> attached patch processes the SHTML to remove *ENTITY* nodes, replacing
>> the “nbsp” entity with an actual non-breaking space; other entities are
>> silently converted to a single space.
>> […]
>> +                              (match entity
>> +                                ("nbsp" (string #\xa0))
>> +                                (_ " "))))
>
> Nice find.  LGTM as far as I can tell, except it would be nice if the ... / … in
> <http://guix.gnu.org/de/packages/guile-hashing-1.2.0/> were not rendered as
> a space.

I will add another case for “hellip”.

I could also convert all descriptions and extract all *ENTITY* tags to
see what entities there are to be be dealt with.

-- 
Ricardo


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

* Re: [website]: Fix rendering of entities.
  2020-09-13  9:48   ` Ricardo Wurmus
@ 2020-09-13 21:52     ` Ricardo Wurmus
  0 siblings, 0 replies; 4+ messages in thread
From: Ricardo Wurmus @ 2020-09-13 21:52 UTC (permalink / raw)
  To: pelzflorian (Florian Pelz); +Cc: guix-devel


Ricardo Wurmus <rekado@elephly.net> writes:

> pelzflorian (Florian Pelz) <pelzflorian@pelzflorian.de> writes:
>
>> On Wed, Sep 09, 2020 at 11:35:06PM +0200, Ricardo Wurmus wrote:
>>> Hi Guix,
>>> 
>>> this page looks wrong: https://guix.gnu.org/packages/mpc-1.1.0/
>>> 
>>> The non-breaking space is rendered as “GNU<*ENTITY*>nbspMPC”.  The
>>> attached patch processes the SHTML to remove *ENTITY* nodes, replacing
>>> the “nbsp” entity with an actual non-breaking space; other entities are
>>> silently converted to a single space.
>>> […]
>>> +                              (match entity
>>> +                                ("nbsp" (string #\xa0))
>>> +                                (_ " "))))
>>
>> Nice find.  LGTM as far as I can tell, except it would be nice if the ... / … in
>> <http://guix.gnu.org/de/packages/guile-hashing-1.2.0/> were not rendered as
>> a space.
>
> I will add another case for “hellip”.
>
> I could also convert all descriptions and extract all *ENTITY* tags to
> see what entities there are to be be dealt with.

I only saw “hellip” and no other entities, so I added an extra case for
“hellip” and pushed the change.

Thanks for your comments!

-- 
Ricardo


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

end of thread, other threads:[~2020-09-13 21:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 21:35 [website]: Fix rendering of entities Ricardo Wurmus
2020-09-12 22:06 ` pelzflorian (Florian Pelz)
2020-09-13  9:48   ` Ricardo Wurmus
2020-09-13 21:52     ` Ricardo Wurmus

unofficial mirror of guix-devel@gnu.org 

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://yhetil.org/guix-devel/0 guix-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 guix-devel guix-devel/ https://yhetil.org/guix-devel \
		guix-devel@gnu.org
	public-inbox-index guix-devel

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.gnu.guix.devel
	nntp://news.gmane.io/gmane.comp.gnu.guix.devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git