From patchwork Sat Feb 3 23:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolas Graves X-Patchwork-Id: 59737 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A678C27BBED; Sat, 3 Feb 2024 23:09:21 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4932B27BBEC for ; Sat, 3 Feb 2024 23:09:20 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rWP81-0008BF-0g; Sat, 03 Feb 2024 18:08:53 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rWP7z-0008Aw-Rs for guix-patches@gnu.org; Sat, 03 Feb 2024 18:08:51 -0500 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rWP7z-0008ED-K0 for guix-patches@gnu.org; Sat, 03 Feb 2024 18:08:51 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rWP8B-0001HW-4z for guix-patches@gnu.org; Sat, 03 Feb 2024 18:09:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#62202] [PATCH v4 3/6] import: juliahub: Beautify description. Resent-From: Nicolas Graves Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 03 Feb 2024 23:09:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 62202 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch moreinfo To: 62202@debbugs.gnu.org Cc: ngraves@ngraves.fr, zimoun.toutoune@gmail.com Received: via spool by 62202-submit@debbugs.gnu.org id=B62202.17070017114846 (code B ref 62202); Sat, 03 Feb 2024 23:09:03 +0000 Received: (at 62202) by debbugs.gnu.org; 3 Feb 2024 23:08:31 +0000 Received: from localhost ([127.0.0.1]:47250 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWP7f-0001G4-Gm for submit@debbugs.gnu.org; Sat, 03 Feb 2024 18:08:31 -0500 Received: from 9.mo584.mail-out.ovh.net ([46.105.40.176]:53255) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rWP7b-0001FI-5O for 62202@debbugs.gnu.org; Sat, 03 Feb 2024 18:08:28 -0500 Received: from director10.ghost.mail-out.ovh.net (unknown [10.109.176.72]) by mo584.mail-out.ovh.net (Postfix) with ESMTP id BBD8E25BDC for <62202@debbugs.gnu.org>; Sat, 3 Feb 2024 23:08:13 +0000 (UTC) Received: from ghost-submission-6684bf9d7b-xfz5d (unknown [10.108.42.33]) by director10.ghost.mail-out.ovh.net (Postfix) with ESMTPS id 565DD1FDEC; Sat, 3 Feb 2024 23:08:13 +0000 (UTC) Received: from ngraves.fr ([37.59.142.103]) by ghost-submission-6684bf9d7b-xfz5d with ESMTPSA id 12T/C13HvmUznggA0jpIEA (envelope-from ); Sat, 03 Feb 2024 23:08:13 +0000 Authentication-Results: garm.ovh; auth=pass (GARM-103G00512037912-6b0e-4dfc-af55-9d499f043c10, CDD90146079FDB87F723A7A7FD21F5F4569C6C59) smtp.auth=ngraves@ngraves.fr X-OVh-ClientIp: 81.67.146.208 Date: Sun, 4 Feb 2024 00:07:13 +0100 Message-ID: <20240203230807.25751-3-ngraves@ngraves.fr> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240203230807.25751-1-ngraves@ngraves.fr> References: <20240203230807.25751-1-ngraves@ngraves.fr> MIME-Version: 1.0 X-Ovh-Tracer-Id: 14365638387764814439 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: 0 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvkedrfedujedgtdejucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecuqfggjfdpvefjgfevmfevgfenuceurghilhhouhhtmecuhedttdenucenucfjughrpefhvfevufffkffojghfggfgsedtkeertdertddtnecuhfhrohhmpefpihgtohhlrghsucfirhgrvhgvshcuoehnghhrrghvvghssehnghhrrghvvghsrdhfrheqnecuggftrfgrthhtvghrnhepleffjeetueethfefkeffffefvddukeejkefgleduiedthfekvefhiedvhfffgeegnecukfhppeduvdejrddtrddtrddupdekuddrieejrddugeeirddvtdekpdefjedrheelrddugedvrddutdefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepuddvjedrtddrtddruddpmhgrihhlfhhrohhmpeeonhhgrhgrvhgvshesnhhgrhgrvhgvshdrfhhrqedpnhgspghrtghpthhtohepuddprhgtphhtthhopeeivddvtddvseguvggssghughhsrdhgnhhurdhorhhgpdfovfetjfhoshhtpehmohehkeegpdhmohguvgepshhmthhpohhuth X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-to: Nicolas Graves X-ACL-Warn: , Nicolas Graves via Guix-patches X-Patchwork-Original-From: Nicolas Graves via Guix-patches via From: Nicolas Graves Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches --- guix/import/juliahub.scm | 53 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/guix/import/juliahub.scm b/guix/import/juliahub.scm index ab838b6035..e4540de06d 100644 --- a/guix/import/juliahub.scm +++ b/guix/import/juliahub.scm @@ -30,8 +30,10 @@ (define-module (guix import juliahub) #:use-module (guix base32) #:use-module (guix packages) #:use-module (guix upstream) - #:use-module (json) #:use-module ((guix licenses) #:prefix license:) + #:use-module (json) + #:use-module (htmlprag) + #:use-module (sxml transform) #:export (juliahub->guix-package %juliahub-updater @@ -76,6 +78,53 @@ (define (ini-fetch url) (close-port port) (map ini-line->alist lines))) +;; Beautify description. +(define %juliahub-beautify-description-rules + `((h1 *preorder* . ,(lambda args #f)) + (h2 *preorder* . ,(lambda args #f)) + (h3 *preorder* . ,(lambda args #f)) + (h4 *preorder* . ,(lambda args #f)) + (h5 *preorder* . ,(lambda args #f)) + (h6 *preorder* . ,(lambda args #f)) + (hr *preorder* . ,(lambda args #f)) + (span *preorder* . ,(lambda args #f)) + (img *preorder* . ,(lambda args #f)) + (pre *preorder* . ,(lambda args #f)) + (div *preorder* . ,(lambda args #f)) + (table *preorder* . ,(lambda args #f)) + (imgalt *preorder* . ,(lambda args #f)) + (@ *preorder* . ,(lambda args #f)) + (*TOP* . ,(lambda args (cdr args))) + (p . ,(lambda args (cdr args))) + (em . ,(lambda args (cdr args))) + (strong . ,(lambda args (cdr args))) + (a . ,(lambda args + (match args + ((tag link ref) + (if ref ref #f)) + (_ #f)))) + (ul . ,(lambda args + `("@itemize" ,@(cdr args) "\n@end itemize"))) + (ol . ,(lambda args + `("@enumerate" ,@(cdr args) "@end enumerate"))) + (blockquote . ,(lambda args + `("@quotation" ,@(cdr args) "@end quotation"))) + (li . ,(lambda args + `("\n@item" ,@(cdr args)))) + (code . ,(lambda args + `("@code{" ,@(cdr args) "}"))) + (*text* . ,(lambda (tag x) x)) + (*default* . ,(lambda (tag . body) + (cons tag body))))) + +(define (juliahub-beautify-description description) + (string-join + (filter (lambda (x) (if (equal? x " ") #f x)) + (flatten + (pre-post-order (html->sxml description) + %juliahub-beautify-description-rules))) + " ")) + ;; Filtering out julia-stdlibs. ;; To update them, see file sysimg.jl. (define %julia-stdlibs @@ -264,7 +313,7 @@ (define* (juliahub->guix-package package-name ((? string?) homepage) (_ (juliahub-package-url package))) (juliahub-package-description package) - (beautify-description + ((compose beautify-description juliahub-beautify-description) (juliahub-package-readme package)) direct-dependencies test-dependencies-names