guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

branch master updated: website: Render non-breaking space and ellipsis c


From: Ricardo Wurmus
Subject: branch master updated: website: Render non-breaking space and ellipsis correctly.
Date: Sun, 13 Sep 2020 17:50:48 -0400

This is an automated email from the git hooks/post-receive script.

rekado pushed a commit to branch master
in repository guix-artwork.

The following commit(s) were added to refs/heads/master by this push:
     new ef4c897  website: Render non-breaking space and ellipsis correctly.
ef4c897 is described below

commit ef4c897b919fcfba5db4225d175b8de7e55b4e70
Author: Ricardo Wurmus <rekado@elephly.net>
AuthorDate: Wed Sep 9 23:32:28 2020 +0200

    website: Render non-breaking space and ellipsis correctly.
    
    * website/apps/packages/utils.scm (texinfo->shtml): Replace *ENTITY*
    nodes with nbsp and hellip entities with the corresponding character;
    replace with a space in case of unknown entities.
---
 website/apps/packages/utils.scm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index fb9d3cf..66edfc6 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,18 @@
   ;; '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))
+                                ("hellip" (string #\x2026))
+                                (_ " "))))
+                        (*default*
+                         . ,(lambda args args))
+                        (*text*
+                         . ,(lambda (_ txt) txt)))))))
 
 (define (package-description-shtml package)
   "Return a SXML representation of PACKAGE description field with HTML



reply via email to

[Prev in Thread] Current Thread [Next in Thread]