From 1dc00c5ddbc6811be42760c8ae37e1d3196f53bf Mon Sep 17 00:00:00 2001 From: Jambunathan K Date: Mon, 4 Jun 2012 03:59:49 +0530 Subject: [PATCH] org-e-odt.el: Handle checkboxes Cleanup lists: Preparing for indented tables (Take 2) Disable listification of deep headings --- contrib/lisp/org-e-html.el | 2 +- contrib/lisp/org-e-odt.el | 137 ++++++++++++++----------------------- 2 files changed, 53 insertions(+), 86 deletions(-) diff --git a/contrib/lisp/org-e-html.el b/contrib/lisp/org-e-html.el index 1ee1e6f2f..4287a5960 100644 --- a/contrib/lisp/org-e-html.el +++ b/contrib/lisp/org-e-html.el @@ -2605,7 +2605,7 @@ the plist used as a communication channel." (extra (if class (format " class=\"%s\"" class) "")) (parent (org-export-get-parent paragraph info))) (cond - ((and (equal (car parent) 'item) + ((and (equal (org-element-type parent) 'item) (= (org-element-property :begin paragraph) (org-element-property :contents-begin parent))) ;; leading paragraph in a list item have no tags diff --git a/contrib/lisp/org-e-odt.el b/contrib/lisp/org-e-odt.el index a7c85e177..3db024be1 100644 --- a/contrib/lisp/org-e-odt.el +++ b/contrib/lisp/org-e-odt.el @@ -233,62 +233,13 @@ structure of the values.") "") (defun org-e-odt-begin-plain-list (ltype &optional continue-numbering) - (let* ((style-name (org-e-odt-get-style-name-for-entity 'list ltype)) - (extra (concat - (if continue-numbering - " text:continue-numbering=\"true\"" - " text:continue-numbering=\"false\"") - (when style-name - (format " text:style-name=\"%s\"" style-name))))) - (case ltype - ((ordered unordered descriptive) - (concat - ;; (org-e-odt-end-paragraph) - (format "" extra))) - (t (error "Unknown list type: %s" ltype))))) + (unless (member ltype '(ordered unordered descriptive)) + (error "Unknown list type: %s" ltype)) -(defun org-e-odt-end-plain-list (ltype) - (if ltype "" - (error "Unknown list type: %s" ltype))) - -(defun org-e-odt-begin-list-item (ltype &optional arg headline) - (case ltype - (ordered - (assert (not headline) t) - (let* ((counter arg) (extra "")) - ;; "" - "")) - (unordered - (let* ((id arg) (extra "")) - (concat - ;; "" - "" - (if headline (org-e-odt-format-target headline id) - (org-e-odt-format-bookmark "" id))))) - (descriptive - (assert (not headline) t) - (let ((term (or arg "(no term)"))) - (concat - (org-e-odt-format-tags - '("" . "") - (org-e-odt-format-stylized-paragraph 'definition-term term)) - (org-e-odt-begin-list-item 'unordered) - (org-e-odt-begin-plain-list 'descriptive) - (org-e-odt-begin-list-item 'unordered)))) - (t (error "Unknown list type")))) - -(defun org-e-odt-end-list-item (ltype) - (case ltype - ((ordered unordered) - ;; "" - "") - (descriptive - (concat - (org-e-odt-end-list-item 'unordered) - (org-e-odt-end-plain-list 'descriptive) - (org-e-odt-end-list-item 'unordered) - )) - (t (error "Unknown list type")))) + (format "" + (org-e-odt-get-style-name-for-entity 'list ltype) + (format "text:continue-numbering=\"%s\"" + (if continue-numbering "true" "false")))) (defun org-e-odt-write-automatic-styles () "Write automatic styles to \"content.xml\"." @@ -2936,17 +2887,18 @@ holding contextual information." ;; Case 2. This is a deep sub-tree: export it as a list item. ;; Also export as items headlines for which no section ;; format has been found. - ((org-export-low-level-p headline info) ; FIXME (or (not section-fmt)) - ;; Build the real contents of the sub-tree. - (let* ((type (if numberedp 'unordered 'unordered)) ; FIXME - (itemized-body (org-e-odt-format-list-item - contents type nil nil full-text))) - (concat - (and (org-export-first-sibling-p headline info) - (org-e-odt-begin-plain-list type)) - itemized-body - (and (org-export-last-sibling-p headline info) - (org-e-odt-end-plain-list type))))) + ;; FIXME + ;; ((org-export-low-level-p headline info) + ;; ;; Build the real contents of the sub-tree. + ;; (let* ((type (if numberedp 'unordered 'unordered)) ; FIXME + ;; (itemized-body (org-e-odt-format-list-item + ;; contents type nil nil full-text))) + ;; (concat + ;; (and (org-export-first-sibling-p headline info) + ;; (org-e-odt-begin-plain-list type)) + ;; itemized-body + ;; (and (org-export-last-sibling-p headline info) + ;; "")))) ;; Case 3. Standard headline. Export it as a section. (t (let* ((extra-ids (list (org-element-property :custom-id headline) @@ -3038,21 +2990,6 @@ contextual information." ;;;; Item -(defun org-e-odt-format-list-item (contents type checkbox - &optional term-counter-id - headline) - (when checkbox - (setq checkbox - (org-e-odt-format-fontify (case checkbox - (on "[X]") - (off "[ ]") - (trans "[-]")) 'code))) - (concat - (org-e-odt-begin-list-item type term-counter-id headline) - ;; FIXME checkbox (and checkbox " ") - contents - (org-e-odt-end-list-item type))) - (defun org-e-odt-item (item contents info) "Transcode an ITEM element from Org to ODT. CONTENTS holds the contents of the item. INFO is a plist holding @@ -3060,11 +2997,27 @@ contextual information." (let* ((plain-list (org-export-get-parent item info)) (type (org-element-property :type plain-list)) (counter (org-element-property :counter item)) - (checkbox (org-element-property :checkbox item)) (tag (let ((tag (org-element-property :tag item))) (and tag (org-export-data tag info))))) - (org-e-odt-format-list-item - contents type checkbox (or tag counter)))) + (case type + (ordered + (format "\n\n%s\n" contents)) + (unordered + (format "\n\n%s\n" contents)) + (descriptive + (concat + (let ((term (or tag "(no term)"))) + (concat + (format "\n\n%s\n" + (org-e-odt-format-stylized-paragraph 'definition-term term)) + (format + "\n\n%s\n" + (format "\n\n%s\n" + (org-e-odt-get-style-name-for-entity 'list 'descriptive) + "text:continue-numbering=\"false\"" + (format "\n\n%s\n" + contents))))))) + (t (error "Unknown list type"))))) ;;;; Keyword @@ -3454,6 +3407,20 @@ the plist used as a communication channel." (center-block 'center) (footnote-definition 'footnote) (t nil)))) + ;; If this paragraph is a leading paragraph in an item and the + ;; item has a checkbox, splice the checkbox and paragraph contents + ;; together. + (when (and (equal (org-element-type parent) 'item) + (= (org-element-property :begin paragraph) + (org-element-property :contents-begin parent))) + (let* ((item parent) + (checkbox (org-element-property :checkbox item)) + (checkbox (and checkbox (org-e-odt-format-fontify + (case checkbox + (on "[✓]") ; CHECK MARK + (off "[ ]") + (trans "[-]")) 'code)))) + (setq contents (concat checkbox (and checkbox " ") contents)))) (org-e-odt-format-stylized-paragraph style contents))) @@ -3471,7 +3438,7 @@ contextual information." (org-e-odt--wrap-label plain-list (format "%s\n%s%s" (org-e-odt-begin-plain-list type) - contents (org-e-odt-end-plain-list type))))) + contents "")))) ;;;; Plain Text