From 7745f78abe8ba03cfc3de7655b7c5d766f5ad5b6 Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus 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 ;;; Copyright © 2017 Eric Bavier +;;; Copyright © 2020 Ricardo Wurmus ;;; ;;; 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