From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Adam Porter Newsgroups: gmane.emacs.devel Subject: Re: [ELPA/elpa-admin] Render README.org as ASCII with ox-ascii Date: Sun, 29 Aug 2021 20:29:15 -0500 Message-ID: <874kb7zpn8.fsf@alphapapa.net> References: <87h7f7zww5.fsf@alphapapa.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3849"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Aug 30 03:30:49 2021 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mKW8O-0000p8-1N for ged-emacs-devel@m.gmane-mx.org; Mon, 30 Aug 2021 03:30:48 +0200 Original-Received: from localhost ([::1]:47004 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKW8M-0006jr-Hf for ged-emacs-devel@m.gmane-mx.org; Sun, 29 Aug 2021 21:30:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:36600) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKW76-0005xa-2z for emacs-devel@gnu.org; Sun, 29 Aug 2021 21:29:28 -0400 Original-Received: from ciao.gmane.io ([116.202.254.214]:59718) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKW74-0004rD-Ia for emacs-devel@gnu.org; Sun, 29 Aug 2021 21:29:27 -0400 Original-Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1mKW6z-0009kb-Ul for emacs-devel@gnu.org; Mon, 30 Aug 2021 03:29:21 +0200 X-Injected-Via-Gmane: http://gmane.org/ Received-SPF: pass client-ip=116.202.254.214; envelope-from=ged-emacs-devel@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: -15 X-Spam_score: -1.6 X-Spam_bar: - X-Spam_report: (-1.6 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:273450 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: > I hope we can generate HTML rather than "clean text", but in the mean > time, clean text is better than raw source, so: thanks. Yes, that shouldn't be a big deal, I think, but it might require a little fiddling to integrate the Org-generated HTML into the ELPA-generated HTML. > There's one problem with your patch, tho: `org-export-as` can run > arbitrary code so we want to run that in a sandbox (and hence in > a separate Emacs process). Oops, I didn't realize that ELPA already had sandbox functions. You're way ahead of me. :) Please see the attached patch, which uses elpaa--call-sandboxed. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-elpa-admin.el-Export-Org-readmes-to-readable-text.patch >From da325b9ef1f9e3ae139256b33a5da7e19eead4b8 Mon Sep 17 00:00:00 2001 From: Adam Porter Date: Sun, 29 Aug 2021 17:45:22 -0500 Subject: [PATCH 2/2] * elpa-admin.el: Export Org readmes to readable text Exports "README.org" files using ox-ascii.el, which is more readable on the ELPA Web site. (elpaa--export-org): New function. (elpaa--get-README): Add docstring, call new function. --- elpa-admin.el | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index ac72f2f..3682bec 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -1210,14 +1210,36 @@ return section under HEADER in package's main file." (buffer-string))))))) (defun elpaa--get-README (pkg-spec dir) - (elpaa--get-section - "Commentary" (elpaa--spec-get pkg-spec :readme - '("README" "README.rst" - ;; Most README.md files seem to be currently - ;; worse than the Commentary: section :-( - ;; "README.md" - "README.org")) - dir pkg-spec)) + "Return readme for PKG-SPEC in DIR as a string. +If readme is an Org file, render it to plain-text using Org +Export." + (let ((readme-file + (elpaa--spec-get pkg-spec :readme + '("README" "README.rst" + ;; Most README.md files seem to be currently + ;; worse than the Commentary: section :-( + ;; "README.md" + "README.org")))) + (pcase readme-file + ("README.org" + (elpaa--export-org readme-file 'ascii '(:ascii-charset utf-8 :with-broken-links t))) + (_ (elpaa--get-section + "Commentary" readme-file + dir pkg-spec))))) + +(defun elpaa--export-org (file backend &optional ext-plist) + "Return Org FILE as an exported string. +BACKEND and EXT-PLIST are passed to `org-export-as', which see. +Uses `elpaa--call-sandboxed', since exporting with Org may run +arbitrary code." + (with-temp-buffer + (unless (zerop (elpaa--call-sandboxed + t "emacs" "--batch" "-l" "ox-ascii" + file + "--eval" (format "(message \"%%s\" (org-export-as '%s nil nil nil '%S))" + backend ext-plist))) + (error "Unable to export Org file: %S" file)) + (buffer-string))) (defun elpaa--get-NEWS (pkg-spec dir) (let ((text -- 2.7.4 --=-=-=--