[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[website]: Fix rendering of entities.
From: |
Ricardo Wurmus |
Subject: |
[website]: Fix rendering of entities. |
Date: |
Wed, 09 Sep 2020 23:35:06 +0200 |
User-agent: |
mu4e 1.4.13; emacs 27.1 |
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
>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
- [website]: Fix rendering of entities.,
Ricardo Wurmus <=