From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id OE3GE3Tg5mFlqgAAgWs5BA (envelope-from ) for ; Tue, 18 Jan 2022 16:44:52 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id +DKHDHTg5mFuuAAAG6o9tA (envelope-from ) for ; Tue, 18 Jan 2022 16:44:52 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id CBAFA8210 for ; Tue, 18 Jan 2022 16:44:51 +0100 (CET) Received: from localhost ([::1]:38492 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9qfB-0007ek-QV for larch@yhetil.org; Tue, 18 Jan 2022 10:44:50 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41866) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9q94-0003ux-QX for emacs-orgmode@gnu.org; Tue, 18 Jan 2022 10:11:38 -0500 Received: from mail.hostpark.net ([212.243.197.30]:35412) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9q92-0007NN-B9 for emacs-orgmode@gnu.org; Tue, 18 Jan 2022 10:11:38 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id 9AE4516BAC for ; Tue, 18 Jan 2022 16:11:32 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=bernoul.li; h= content-transfer-encoding:mime-version:references:in-reply-to :x-mailer:message-id:date:date:subject:subject:from:from :received:received; s=sel2011a; t=1642518690; bh=41nJ0Clucx0rKs9 TRlSXauRnHEera1WY16YmFxeeqII=; b=JBSpVKtyuObnLm+j1rcWpRWI0iXYtWr FZ+nChKmToZ0iRqHZ6Q3cSk9UqNkOk+FVEtIFWwB8IXdLA1bn3d0j5+aMvujN9LK 00ASe3qtzEpkn7OPVrPJF9W50M/PxRryWyfDnaFst1yCm6PA3pQLgcmxhN0tEGyp vrJ6BxjPTxlU= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail0.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id oURM1vAuqUik for ; Tue, 18 Jan 2022 16:11:30 +0100 (CET) Received: from customer (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.hostpark.net (Postfix) with ESMTPSA id 6019C16BAF for ; Tue, 18 Jan 2022 16:11:30 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v3 2/3] ox-texinfo: Optionally use @itemx for certain description list items Date: Tue, 18 Jan 2022 16:11:28 +0100 Message-Id: <20220118151129.19646-3-jonas@bernoul.li> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220118151129.19646-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220118151129.19646-1-jonas@bernoul.li> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: none client-ip=212.243.197.30; envelope-from=jonas@bernoul.li; helo=mail.hostpark.net X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642520691; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=Q2aGC/UAT8oTLkoxQKnO4Hx9IYdQJEbwS7adSl3K4To=; b=msygktvsSAI58CsL7uX/L20P7pcljD4rj/9sTlSCy/HyjjaxuuzrW3+leY7iQLDBLLr2v1 m7kdU+g19ymo2ZWPSXfKWeoJABwsY20hcIb2J26soOgOl45x+kmTpPtJNubvJfcT+nNrbI O2e5y9mdAs1QB3bEC5XWYyBcD0HkmI/fNGMZzrPZxZlAhPfnvkk7wYcIlf4SmeHrvfxMIp R3dsFr0fzRWQAOHoUl3DZ5PorHnsPS+7WC3JJYQzNbJ4XCn+zHtKOatyrn9uwWQP0ccuhP 81Dw+7RaTKgcbGF392b1sxTP+Z72MuTP4I634HFtHtjq0f2Wsovr97YWm0v7Ow== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642520691; a=rsa-sha256; cv=none; b=K2irtEZsj/W5QzBPefcPeUP31vIWluGc++LaZrAj2WDeXNgDyNY+2GMliiCfIcne3eVrAs 8sqRS455cZDRrdxn8PoYcmhvM5Ve2SeOBopf/bD6NJEAu/OPriuBOezTaqgAC+KyEQonlf GdRCYqWDoURqlV51EBtjUkNb3Vw/nRce+UAFZey9a0hpavaGMLYJa5RY+3qhoOKj82A+35 swbUPcmR1dUuMItydph0Q/HZDjnsisjihw0eYepSCzoRYcCr+WKg5QejW8cg21VwFo7NUZ 9PS7ZZjQdQw96lx0xeMFyL1e0SbR3JLzN8UHuEiaD35Fz9XfPDRgji65Y7pqSg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=JBSpVKty; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Spam-Score: -2.42 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=JBSpVKty; dmarc=none; spf=pass (aspmx1.migadu.com: domain of "emacs-orgmode-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="emacs-orgmode-bounces+larch=yhetil.org@gnu.org" X-Migadu-Queue-Id: CBAFA8210 X-Spam-Score: -2.42 X-Migadu-Scanner: scn1.migadu.com X-TUID: j24tTpdUchsW * doc/org-manual.org (Plain lists in Texinfo export): Reorder and document new functionality. * lisp/ox-texinfo.el: Add org-texinfo--combine-items to the list of :filter-parse-tree functions of the texinfo backend. * lisp/ox-texinfo.el (org-texinfo--combine-items) New function. * lisp/ox-texinfo.el (org-texinfo-item) Transcode combined items to one @item and one or more @itemx. --- doc/org-manual.org | 38 +++++++++++++++++++++++++----------- lisp/ox-texinfo.el | 48 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 71 insertions(+), 15 deletions(-) diff --git a/doc/org-manual.org b/doc/org-manual.org index a5aac7d61..b3c4a9bef 100644 --- a/doc/org-manual.org +++ b/doc/org-manual.org @@ -15236,6 +15236,23 @@ This paragraph is preceded by... :DESCRIPTION: List attributes. :END: +#+cindex: lettered lists, in Texinfo export +#+cindex: enum, Texinfo attribute +The Texinfo export back-end converts unordered and ordered lists in +the Org file using the default command =@itemize=. + +Ordered lists are numbered when exported to Texinfo format. Such +numbering obeys any counter (see [[*Plain Lists]]) in the first item of +the list. The =:enum= attribute also let you start the list at a +specific number, or switch to a lettered list, as illustrated here: + +#+begin_example +#+ATTR_TEXINFO: :enum A +1. Alpha +2. Bravo +3. Charlie +#+end_example + #+cindex: @samp{ATTR_TEXINFO}, keyword #+cindex: two-column tables, in Texinfo export #+cindex: table-type, Texinfo attribute @@ -15262,7 +15279,7 @@ entry in the first column of the table. The following example illustrates all the attributes above: #+begin_example -,#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis +,#+attr_texinfo: :table-type vtable :indic asis :sep , - foo, bar :: This is the common text for variables foo and bar. #+end_example @@ -15277,18 +15294,17 @@ This is the common text for variables foo and bar. @end table #+end_example -#+cindex: lettered lists, in Texinfo export -#+cindex: enum, Texinfo attribute -Ordered lists are numbered when exported to Texinfo format. Such -numbering obeys any counter (see [[*Plain Lists]]) in the first item of -the list. The =:enum= attribute also let you start the list at -a specific number, or switch to a lettered list, as illustrated here +The =:combine= attribute is an alternative to the =:sep= attribute, +which allows writing each entry on its own line. If this attribute is +non-nil and an item in a description list has no body but is followed +by another item, then the second item is transcoded to =@itemx=. This +example is transcoded to the same output as above. #+begin_example -#+ATTR_TEXINFO: :enum A -1. Alpha -2. Bravo -3. Charlie +,#+attr_texinfo: :table-type vtable :indic asis :combine t +- foo :: +- bar :: + This is the common text for variables foo and bar. #+end_example *** Tables in Texinfo export diff --git a/lisp/ox-texinfo.el b/lisp/ox-texinfo.el index 57cbcf6ad..36e1436d7 100644 --- a/lisp/ox-texinfo.el +++ b/lisp/ox-texinfo.el @@ -83,7 +83,8 @@ (org-export-define-backend 'texinfo (verse-block . org-texinfo-verse-block)) :filters-alist '((:filter-headline . org-texinfo--filter-section-blank-lines) - (:filter-parse-tree . org-texinfo--normalize-headlines) + (:filter-parse-tree . (org-texinfo--normalize-headlines + org-texinfo--combine-items)) (:filter-section . org-texinfo--filter-section-blank-lines) (:filter-final-output . org-texinfo--untabify)) :menu-entry @@ -421,7 +422,7 @@ (defun org-texinfo--filter-section-blank-lines (headline _backend _info) (defun org-texinfo--normalize-headlines (tree _backend info) "Normalize headlines in TREE. -BACK-END is the symbol specifying back-end used for export. +_BACKEND is the symbol `texinfo'; the back-end used for export. INFO is a plist used as a communication channel. Make sure every headline in TREE contains a section, since those @@ -443,6 +444,40 @@ (defun org-texinfo--normalize-headlines (tree _backend info) info) tree) +(defun org-texinfo--combine-items (tree _backend info) + "Combine certain description list items. + +_BACKEND is the symbol `texinfo'; the back-end used for export. +INFO is a plist used as a communication channel. + +If the `:combine' attribute of a description list is non-nil and +an item in that list has no body and is followed by another item, +then remove the first item and prepend its `:tag' to that of the +second item. + +Such an item that absorbed the tags of other items is later +transcoded to one `@item', followed by one or more `@itemx'. + +Return new tree." + (org-element-map tree 'item + (lambda (item) + (let ((plain-list (org-element-property :parent item))) + (when (and (org-not-nil (org-export-read-attribute + :attr_texinfo plain-list :compact)) + (eq (org-element-property :type plain-list) 'descriptive)) + (let ((next-item + (cadr (memq item (org-element-contents plain-list))))) + (when (and next-item + (not (org-element-contents item)) + (= (org-element-property :post-blank item) 1)) + (org-element-put-property + next-item :itemx + (nconc (org-element-property :itemx item) + (list (org-element-property :tag item)))) + (org-element-extract-element item)))))) + info) + tree) + (defun org-texinfo--find-verb-separator (s) "Return a character not used in string S. This is used to choose a separator for constructs like \\verb." @@ -994,8 +1029,13 @@ (defun org-texinfo-item (item contents info) (org-export-read-attribute :attr_texinfo (org-element-property :parent item) :sep))) - (items (and tag - (let ((tag (org-export-data tag info))) + (items (org-element-property :itemx item)) + (items (cond (items + (mapcar (lambda (tag) (org-export-data tag info)) + (nconc items (list tag)))) + ((not tag) nil) + (t + (setq tag (org-export-data tag info)) (if split (split-string tag (regexp-quote split) t "[ \t\n]+") (list tag)))))) -- 2.34.1