[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/10: website: packages: Interpret synopsis/description Texinfo.
From: |
Ludovic Courtès |
Subject: |
07/10: website: packages: Interpret synopsis/description Texinfo. |
Date: |
Sat, 29 Jul 2017 12:33:19 -0400 (EDT) |
civodul pushed a commit to branch wip-website-update
in repository guix-artwork.
commit 0914764478605dd8c6154f39ae5372e24c7ffe81
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.
- branch wip-website-update created (now cf672e3), Ludovic Courtès, 2017/07/29
- 05/10: website: utils: 'paginate' correctly handles the case with zero items., Ludovic Courtès, 2017/07/29
- 03/10: website: posts: Add missing tags and harmonize., Ludovic Courtès, 2017/07/29
- 02/10: website: packages: Ignore third-party packages., Ludovic Courtès, 2017/07/29
- 04/10: website: Rename 'guix.scm' to 'build.scm'., Ludovic Courtès, 2017/07/29
- 09/10: website: packages: Fix typo., Ludovic Courtès, 2017/07/29
- 10/10: website: packages: Implement patch links., Ludovic Courtès, 2017/07/29
- 07/10: website: packages: Interpret synopsis/description Texinfo.,
Ludovic Courtès <=
- 08/10: website: packages: Add the commit in package source URLs., Ludovic Courtès, 2017/07/29
- 06/10: website: packages: Implement grouping by letter., Ludovic Courtès, 2017/07/29