From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id o0pWIZCg1WFLLQEAgWs5BA (envelope-from ) for ; Wed, 05 Jan 2022 14:43:44 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id cL1aHZCg1WEz5gAAauVa8A (envelope-from ) for ; Wed, 05 Jan 2022 14:43:44 +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 C636335082 for ; Wed, 5 Jan 2022 14:43:43 +0100 (CET) Received: from localhost ([::1]:59600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n56Zq-0007kj-Ql for larch@yhetil.org; Wed, 05 Jan 2022 08:43:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:44960) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n56N7-00057j-9E for emacs-orgmode@gnu.org; Wed, 05 Jan 2022 08:30:35 -0500 Received: from mail.hostpark.net ([212.243.197.30]:46982) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n56N3-0001VP-HC for emacs-orgmode@gnu.org; Wed, 05 Jan 2022 08:30:32 -0500 Received: from localhost (localhost [127.0.0.1]) by mail.hostpark.net (Postfix) with ESMTP id A8AAE1647F for ; Wed, 5 Jan 2022 14:30:27 +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=1641389425; bh=LEWp71BNxauiPwv XReGoqS7gLKS/Rgxp8DdH3vlCnm4=; b=VB+7YF5f25lXqpWlKhNwdwmXEc8VbXK LGYmv5PRmaaIghizZK/yxL3KLZbAng3D7vcfzD7KwRD7uwtvdk/tzlL9YXWFk97M glIT46WJqXn+ohyTaRmH6sM1EKx18Qb+QkffzeJzeUQjBxOlN5k+4qpm4zeLKEFy ahMVKkEWZ6wU= X-Virus-Scanned: by Hostpark/NetZone Mailprotection at hostpark.net Received: from mail.hostpark.net ([127.0.0.1]) by localhost (mail1.hostpark.net [127.0.0.1]) (amavisd-new, port 10224) with ESMTP id bwnEotDUi6sc for ; Wed, 5 Jan 2022 14:30:25 +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 721A4164A8 for ; Wed, 5 Jan 2022 14:30:25 +0100 (CET) From: Jonas Bernoulli To: emacs-orgmode@gnu.org Subject: [PATCH v2 2/3] ox-texinfo: Optionally use @itemx for certain description list items Date: Wed, 5 Jan 2022 14:30:24 +0100 Message-Id: <20220105133025.12624-3-jonas@bernoul.li> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220105133025.12624-1-jonas@bernoul.li> References: <20211218214038.9459-1-jonas@bernoul.li> <20220105133025.12624-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=1641390223; 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=nNc3AX58/trIV8q4CetlWCsXdWe9TyhXalXml4BjAqg=; b=le30SqOFYJpnFkwvPf/s1ArS/zRdthiRsxzbxT58xznHam6jwTefs5KQqIjqJmdcljYkcS g/8ZgDLzLN3RxB8fXRUayLhTQBfVAfa5QBr+6WzGMtqjdr5TZoQs1Ax6hc1qevZGxnyvsQ 5kX8YNok5MaPYdIoWzYLNMkCBw0sZX6bWzJdkpYR8+BbJW/8YtDCeOS0Tt7ltxnAxLy+XU 1vZGUF9Zc/OV6lx4vlPWs9N/9fdRQpIYt+3WmPfcKqR2HND0faKXfPp5Uv1X90+76qdYb2 qUfGJuQf1jS5A0Ras69x+GevBbCAE/i2AuVUOVW1Cow/ebSxThOwJNBRYUzJ3A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1641390223; a=rsa-sha256; cv=none; b=YVpJaQdDLFdH8bUqSuWE17iJMwyvxW0SeRAO0BHsuPezviZWDPxVWsRsgfl9dPIXCT6aKN wyrMyeTxWN+P5Mpu3Tb542HEzQRHyLwc61RQdf2K3U/Epce7ngsYu+kDZBUeT5602LyZvW /oHSCdvYwd/uXWuYphG+e6JXqT2cjtso3yNWlUpHdbh9cCTQ0EsO7UChkZNNO8T7+f4uFG 4ibPVZtwAx+SnHochvzGruXA+4AOr5d9Y0KIyyArOj1X0cEe2pH6Ed0OCOrj37+9ZXRY+R 4HNhS1YgWlCCyVUndXfUSpIuvUKYlzUu77eYpfWWqj8UDBO0VIDlIiTKnF/y6A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=VB+7YF5f; 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: -3.80 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=bernoul.li header.s=sel2011a header.b=VB+7YF5f; 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: C636335082 X-Spam-Score: -3.80 X-Migadu-Scanner: scn0.migadu.com X-TUID: LVMnrKucaXEB * 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 | 45 +++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 68 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..8f671ea13 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,37 @@ (defun org-texinfo--normalize-headlines (tree _backend info) info) tree) +(defun org-texinfo--combine-items (tree _backend info) + "Normalize items in TREE. + +_BACKEND is the symbol `texinfo'; the back-end used for export. +INFO is a plist used as a communication channel. + +Items in description lists that use the \"+\" bullet are +converted to `@itemx'. If another item is followed by such an +item, then the first item should not be followed by a space, +which this function takes care of. + +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 +1026,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