guix-commits
[Top][All Lists]
Advanced

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

07/12: website: packages: Interpret synopsis/description Texinfo.


From: Ludovic Courtès
Subject: 07/12: website: packages: Interpret synopsis/description Texinfo.
Date: Sun, 30 Jul 2017 16:23:17 -0400 (EDT)

civodul pushed a commit to branch wip-website-update
in repository guix-artwork.

commit db3818d9cd5b8736ac527fe82a419b9c5ebbd286
Author: Ludovic Courtès <address@hidden>
Date:   Sat Jul 29 17:46:00 2017 +0200

    website: packages: Interpret synopsis/description Texinfo.
    
    * website/apps/packages/utils.scm (texinfo->shtml)
    (package-description-shtml, package-synopsis-shtml): New procedures.
    * website/apps/packages/templates/components.scm (detailed-package-preview):
    Use them.
    * website/apps/packages/templates/package.scm (package-t): Use them.
---
 website/apps/packages/templates/components.scm |  4 +-
 website/apps/packages/templates/package.scm    |  6 +--
 website/apps/packages/utils.scm                | 51 ++++++++++++++++++++++++--
 3 files changed, 53 insertions(+), 8 deletions(-)

diff --git a/website/apps/packages/templates/components.scm 
b/website/apps/packages/templates/components.scm
index d4fedee..48c06e5 100644
--- a/website/apps/packages/templates/components.scm
+++ b/website/apps/packages/templates/components.scm
@@ -38,10 +38,10 @@
      (span
       (@ (class "package-synopsis"))
       " — "
-      ,(package-synopsis package)))
+      ,(package-synopsis-shtml package)))
     (p
      (@ (class "package-description"))
-     ,(package-description package))
+     ,(package-description-shtml package))
 
     (ul
      (@ (class "package-info"))
diff --git a/website/apps/packages/templates/package.scm 
b/website/apps/packages/templates/package.scm
index 86d64da..178a567 100644
--- a/website/apps/packages/templates/package.scm
+++ b/website/apps/packages/templates/package.scm
@@ -23,7 +23,7 @@
         (lint-issues (package-lint-issues package)))
     (theme
      #:title (list package-id "Packages")
-     #:description (package-synopsis package)
+     #:description (package-synopsis-shtml package)
      #:keywords
      '("GNU" "Linux" "Unix" "Free software" "Libre software"
        "Operating system" "GNU Hurd" "GNU Guix package manager"
@@ -44,9 +44,9 @@
        (h2 ,package-id " "
            (span
             (@ (class "synopsis"))
-            ,(package-synopsis package)))
+            ,(package-synopsis-shtml package)))
 
-       (p ,(package-description package))
+       (p ,(package-description-shtml package))
 
        (ul
         (@ (class "package-info"))
diff --git a/website/apps/packages/utils.scm b/website/apps/packages/utils.scm
index 4e435be..1ca8069 100644
--- a/website/apps/packages/utils.scm
+++ b/website/apps/packages/utils.scm
@@ -1,6 +1,23 @@
 ;;; GuixSD website --- GNU's advanced distro website
-;;; Initially written by sirgazil who waves all
-;;; copyright interest on this file.
+;;; Copyright © 2017 Ludovic Courtès <address@hidden>
+;;;
+;;; Initially written by sirgazil
+;;; who waives all copyright interest on this file.
+;;;
+;;; This file is part of GuixSD website.
+;;;
+;;; GuixSD website is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU Affero General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GuixSD website is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU Affero General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU Affero General Public License
+;;; along with GuixSD website.  If not, see <http://www.gnu.org/licenses/>.
 
 (define-module (apps packages utils)
   #:use-module (apps aux web)
@@ -9,8 +26,13 @@
   #:use-module (apps packages types)
   #:use-module (guix packages)
   #:use-module (guix utils)
+  #:use-module (texinfo)
+  #:use-module (texinfo html)
   #:use-module (ice-9 match)
-  #:export (location->ilink
+  #:export (package-description-shtml
+            package-synopsis-shtml
+
+            location->ilink
            package-build-issues
            package-issues?
            package-lint-issues
@@ -23,6 +45,29 @@
 ;;; Helper procedures.
 ;;;
 
+(define (texinfo->shtml texi)
+  "Parse TEXI, a string, and return the corresponding SHTML."
+  ;; '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))))
+
+(define (package-description-shtml package)
+  "Return a SXML representation of PACKAGE description field with HTML
+vocabulary."
+  (and=> (package-description package) texinfo->shtml))
+
+(define (package-synopsis-shtml package)
+  "Return a SXML representation of PACKAGE synopsis field with HTML
+vocabulary."
+  (and=> (package-synopsis package)
+         (lambda (synopsis)
+           ;; Strip the paragraph that 'texinfo->shtml' adds.
+           (match (texinfo->shtml synopsis)
+             (('div ('p text ...))
+              text)))))
+
+
 (define (location->ilink loc)
   "Convert the given location LOC into an Ilink.
 



reply via email to

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