I need time to review other issues you are raising. Georg Lehner <jorge-...@magma.com.ni> writes: > 4. LaTeX like definition lists
Here is a patch and sample documents. You can pull from my private repo which is at http://repo.or.cz/w/org-mode/org-kjn.git
>From 7dfa274163fb3a06ff947e1af884af49dca34b0e Mon Sep 17 00:00:00 2001 From: Jambunathan K <kjambunat...@gmail.com> Date: Sat, 29 Jun 2013 17:59:48 +0530 Subject: [PATCH] ox-odt: Support for typesetting Description lists as in LaTeX * etc/styles.OrgOdtStyles.xml (OrgDescriptionTerm) (OrgDescriptionDefinition): New styles for typesetting description lists. * lisp/ox-odt.el (org-odt-description-list-style): New user option. (org-odt--translate-description-lists/html): Renmed from `org-odt--translate-description-lists. Use new style "OrgDescriptionTerm". Update comments. (org-odt--translate-description-lists/latex): New. (org-odt-bold): Add an internal `:style' property. --- etc/styles/OrgOdtStyles.xml | 10 +++ lisp/ox-odt.el | 141 +++++++++++++++++++++++++++++++++++++----- 2 files changed, 134 insertions(+), 17 deletions(-) diff --git a/etc/styles/OrgOdtStyles.xml b/etc/styles/OrgOdtStyles.xml index f41d984..c2c32fa 100644 --- a/etc/styles/OrgOdtStyles.xml +++ b/etc/styles/OrgOdtStyles.xml @@ -729,6 +729,16 @@ </text:list-level-style-number> </text:list-style> + <style:style style:name="OrgDescriptionTerm" style:family="text"> + <style:text-properties fo:font-weight="bold"/> + </style:style> + + <style:style style:name="OrgDescriptionDefinition" style:family="paragraph" style:parent-style-name="Text_20_body" style:class="text"> + <style:paragraph-properties fo:margin-left="0.64cm" fo:margin-right="0cm" fo:text-indent="-0.64cm" style:auto-text-indent="false"> + <style:tab-stops/> + </style:paragraph-properties> + </style:style> + <text:list-style style:name="OrgSrcBlockNumberedLine"> <text:list-level-style-number text:level="1" style:num-format="1"> <style:list-level-properties text:space-before="0.635cm" text:min-label-width="0.635cm" text:min-label-distance="0.101cm" fo:text-align="end"/> diff --git a/lisp/ox-odt.el b/lisp/ox-odt.el index a76f7dd..0eaffcb 100644 --- a/lisp/ox-odt.el +++ b/lisp/ox-odt.el @@ -86,7 +86,7 @@ (org-export-define-backend 'odt :export-block "ODT" :filters-alist '((:filter-parse-tree . (org-odt--translate-latex-fragments - org-odt--translate-description-lists + org-odt--translate-description-lists ; Dummy symbol org-odt--translate-list-tables))) :menu-entry '(?o "Export to ODT" @@ -777,6 +777,22 @@ (defcustom org-odt-pixels-per-inch display-pixels-per-inch :version "24.1") +;;;; Lists + +(defcustom org-odt-description-list-style #'org-odt--translate-description-lists/html + "Specify how description lists are rendered. +Choose one of HTML or LaTeX style." + :type '(choice + (const :tag "Use HTML style" org-odt--translate-description-lists/html ) + (const :tag "Use LaTeX style" org-odt--translate-description-lists/latex )) + :group 'org-export-odt + :set (lambda (symbol value) + "Alias `org-odt--translate-description-lists'." + (set-default symbol value) + (fset 'org-odt--translate-description-lists value)) + :version "24.1") + + ;;;; Src Block (defcustom org-odt-create-custom-styles-for-srcblocks t @@ -1583,7 +1599,11 @@ (defun org-odt-bold (bold contents info) CONTENTS is the text with bold markup. INFO is a plist holding contextual information." (format "<text:span text:style-name=\"%s\">%s</text:span>" - "Bold" contents)) + ;; Internally, `org-odt--translate-description-lists/html' + ;; or `org-odt--translate-description-lists/latex' requests + ;; a custom style for bold. + (or (org-element-property :style bold) "Bold") + contents)) ;;;; Center Block @@ -3650,7 +3670,7 @@ (defun org-odt-table (table contents info) ;; item, but also within description lists and low-level ;; headlines. - ;; See `org-odt-translate-description-lists' and + ;; See `org-odt--translate-description-lists' and ;; `org-odt-translate-low-level-headlines' for how this is ;; tackled. @@ -3869,27 +3889,44 @@ (defun org-odt--translate-latex-fragments (tree backend info) ;; This translator is necessary to handle indented tables in a uniform ;; manner. See comment in `org-odt--table'. -(defun org-odt--translate-description-lists (tree backend info) +;; Depending on user option `org-odt-description-list-style', +;; description lists can be typeset either as in HTML documents or as +;; in LaTeX documents. + +(defun org-odt--translate-description-lists/html (tree backend info) ;; OpenDocument has no notion of a description list. So simulate it ;; using plain lists. Description lists in the exported document ;; are typeset in the same manner as they are in a typical HTML - ;; document. + ;; document. See `org-odt--translate-description-lists/latex' for + ;; yet another way of translation. ;; ;; Specifically, a description list like this: ;; - ;; ,---- - ;; | - term-1 :: definition-1 - ;; | - term-2 :: definition-2 - ;; `---- + ;; ,---- + ;; | - term-1 :: definition-1 + ;; | + ;; | paragraph-1 + ;; | + ;; | - term-2 :: definition-2 + ;; | + ;; | paragraph-2 + ;; `---- ;; ;; gets translated in to the following form: ;; - ;; ,---- - ;; | - term-1 - ;; | - definition-1 - ;; | - term-2 - ;; | - definition-2 - ;; `---- + ;; ,---- + ;; | - term-1 + ;; | + ;; | - definition-1 + ;; | + ;; | paragraph-1 + ;; | + ;; | - term-2 + ;; | + ;; | - definition-2 + ;; | + ;; | paragraph-2 + ;; `---- ;; ;; Further effect is achieved by fixing the OD styles as below: ;; @@ -3912,8 +3949,9 @@ (defun org-odt--translate-description-lists (tree backend info) (org-element-adopt-elements (list 'item (list :checkbox (org-element-property :checkbox item))) - (list 'paragraph (list :style "Text_20_body_20_bold") - (or (org-element-property :tag item) "(no term)")) + (list 'paragraph nil + (list 'bold (list :style "OrgDescriptionTerm") + (or (org-element-property :tag item) "(no term)"))) (org-element-adopt-elements (list 'plain-list (list :type 'descriptive-2)) (apply 'org-element-adopt-elements @@ -3924,6 +3962,75 @@ (defun org-odt--translate-description-lists (tree backend info) info) tree) +(defun org-odt--translate-description-lists/latex (tree backend info) + ;; OpenDocument has no notion of a description list. So simulate it + ;; using plain lists. Description lists in the exported document + ;; are typeset in the same manner as they are in a typical LaTeX + ;; style document. See `org-odt--translate-description-lists/html' + ;; for yet another way of translation. + ;; + ;; Specifically, a description list like this: + ;; + ;; ,---- + ;; | - term-1 :: definition-1 + ;; | + ;; | paragraph-1 + ;; | + ;; | - term-2 :: definition-2 + ;; | + ;; | paragraph-2 + ;; `---- + ;; + ;; gets translated in to the following form: + ;; + ;; ,---- + ;; | - *term-1* definition-1 + ;; | + ;; | - paragraph-1 + ;; | + ;; | - *term-2* definition-2 + ;; | + ;; | - paragraph-2 + ;; `---- + ;; + ;; Further effect is achieved by fixing the OD styles as below: + ;; + ;; 1. Set the :type property of the simulated lists to + ;; `descriptive-1' and `descriptive-2'. Map these to list-styles + ;; that has *no* bullets whatsoever. + ;; + ;; 2. The paragraph containing the definition term is styled to be + ;; use hanging indent. + ;; + (org-element-map tree 'plain-list + (lambda (el) + (when (equal (org-element-property :type el) 'descriptive) + (org-element-set-element + el + (apply 'org-element-adopt-elements + (list 'plain-list (list :type 'descriptive-1)) + (mapcar + (lambda (item) + (let* ((item-contents (org-element-contents item)) + (leading-paragraph (car item-contents)) + (item-contents (cdr item-contents))) + (org-element-adopt-elements + (list 'item (list :checkbox (org-element-property :checkbox item))) + (apply 'org-element-adopt-elements + (list 'paragraph (list :style "OrgDescriptionDefinition")) + (list 'bold (list :style "OrgDescriptionTerm" :post-blank 1) + (or (org-element-property :tag item) "(no term)")) + (org-element-contents leading-paragraph)) + (org-element-adopt-elements + (list 'plain-list (list :type 'descriptive-2)) + (apply 'org-element-adopt-elements + (list 'item nil) + item-contents))))) + (org-element-contents el))))) + nil) + info) + tree) + ;;;; List tables ;; Lists that are marked with attribute `:list-table' are called as -- 1.7.2.5
* One - term-1 :: definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 definition-1 Some paragraph. | a | b | c | | d | e | f | - term-2 :: definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 definition-2 Another paragraph.
dl.latex.odt
Description: application/vnd.oasis.opendocument.text
dl.html.odt
Description: application/vnd.oasis.opendocument.text