all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / 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 related	[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

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

	https://git.savannah.gnu.org/cgit/guix.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.