Bläddra i källkod

ox-texinfo: Implement the :sep attribute in plain lists

* lisp/ox-texinfo.el (org-texinfo-item):
* doc/org.texi (Plain lists in Texinfo export):
Nicolas Goaziou 8 år sedan
förälder
incheckning
8dc31ed680
3 ändrade filer med 53 tillägg och 8 borttagningar
  1. 28 4
      doc/org.texi
  2. 6 0
      etc/ORG-NEWS
  3. 19 4
      lisp/ox-texinfo.el

+ 28 - 4
doc/org.texi

@@ -13699,21 +13699,45 @@ This paragraph is preceded by...
 @node Plain lists in Texinfo export
 @subsection Plain lists in Texinfo export
 @cindex #+ATTR_TEXINFO, in plain lists
+@cindex Two-column tables, in Texinfo export
+
+@cindex :table-type attribute, in Texinfo export
 The Texinfo export back-end by default converts description lists in the Org
 file using the default command @code{@@table}, which results in a table with
 two columns.  To change this behavior, specify @code{:table-type} with
-@code{@@ftable} or @code{@@vtable} attributes.  For more information,
+@code{ftable} or @code{vtable} attributes.  For more information,
 @inforef{Two-column Tables,,texinfo}.
 
 @vindex org-texinfo-def-table-markup
+@cindex :indic attribute, in Texinfo export
 The Texinfo export back-end by default also applies a text highlight based on
 the defaults stored in @code{org-texinfo-def-table-markup}.  To override the
 default highlight command, specify another one with the @code{:indic}
-attribute as shown in this example:
+attribute.
+
+@cindex Multiple entries in two-column tables, in Texinfo export
+@cindex :separator attribute, in Texinfo export
+Org syntax is limited to one entry per list item.  Nevertheless, the Texinfo
+export back-end can split that entry according to any text provided through
+the @code{:sep} attribute.  Each part then becomes a new entry in the first
+column of the table.
+
+The following example illustrates all the attributes above:
+
+@example
+#+ATTR_TEXINFO: :table-type vtable :sep , :indic asis
+- foo, bar :: This is the common text for variables foo and bar.
+@end example
+
+@noindent
+becomes
 
 @example
-#+ATTR_TEXINFO: :indic @@asis
-- foo :: This is the text for /foo/, with no highlighting.
+@@vtable @@asis
+@@item foo
+@@itemx bar
+This is the common text for variables foo and bar.
+@@end table
 @end example
 
 @node Tables in Texinfo export

+ 6 - 0
etc/ORG-NEWS

@@ -208,6 +208,12 @@ user to specify the name of the output file upon exporting the
 document.  This also has an effect on publishing.
 **** Horizontal rules are no longer ignored in LaTeX table math mode
 **** Use ~compilation-mode~ for compilation output
+**** Plain lists accept a new ~:separator~ attribute in Texinfo
+
+The new ~:separator~ attribute splits a tag from a description list
+item into multiple parts.  This allows to have two-column tables with
+multiple entries in the first column.  See manual for more details.
+
 **** ~latex-environment~ elements support ~caption~ keywords for LaTeX export
 *** ~org-edit-special~ can edit LaTeX environments
 

+ 19 - 4
lisp/ox-texinfo.el

@@ -920,10 +920,25 @@ contextual information."
   "Transcode an ITEM element from Org to Texinfo.
 CONTENTS holds the contents of the item.  INFO is a plist holding
 contextual information."
-  (format "@item%s\n%s"
-	  (let ((tag (org-element-property :tag item)))
-	    (if tag (concat " " (org-export-data tag info)) ""))
-	  (or contents "")))
+  (let* ((tag (org-element-property :tag item))
+	 (split (org-string-nw-p
+		 (org-export-read-attribute :attr_texinfo
+					    (org-element-property :parent item)
+					    :sep)))
+	 (items (and tag
+		     (let ((tag (org-export-data tag info)))
+		       (if split (split-string tag split t "[ \t\n]+")
+			 (list tag))))))
+    (format "%s\n%s"
+	    (pcase items
+	      (`nil "@item")
+	      (`(,item) (concat "@item " item))
+	      (`(,item . ,items)
+	       (concat "@item " item "\n"
+		       (mapconcat (lambda (i) (concat "@itemx " i))
+				  items
+				  "\n"))))
+	    (or contents ""))))
 
 ;;;; Keyword