all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <rekado@elephly.net>
To: guix-devel@gnu.org
Subject: [website]: Fix rendering of entities.
Date: Wed, 09 Sep 2020 23:35:06 +0200	[thread overview]
Message-ID: <87mu1y63cl.fsf@elephly.net> (raw)

[-- 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


             reply	other threads:[~2020-09-09 21:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09 21:35 Ricardo Wurmus [this message]
2020-09-12 22:06 ` [website]: Fix rendering of entities pelzflorian (Florian Pelz)
2020-09-13  9:48   ` Ricardo Wurmus
2020-09-13 21:52     ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87mu1y63cl.fsf@elephly.net \
    --to=rekado@elephly.net \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.