浏览代码

ox-odt: Fix handling of quoted and centered paragraphs

* lisp/ox-odt.el (org-odt--paragraph-style): New function.
(org-odt--format-paragraph): Use new function to get proper style to
apply.

Thanks to Baptiste for reporting it.
http://permalink.gmane.org/gmane.emacs.orgmode/88798
Nicolas Goaziou 10 年之前
父节点
当前提交
776972cfe8
共有 1 个文件被更改,包括 24 次插入13 次删除
  1. 24 13
      lisp/ox-odt.el

+ 24 - 13
lisp/ox-odt.el

@@ -2832,6 +2832,17 @@ INFO is a plist holding contextual information.  See
 
 ;;;; Paragraph
 
+(defun org-odt--paragraph-style (paragraph)
+  "Return style of PARAGRAPH.
+Style is a symbol among `quoted', `centered' and nil."
+  (let ((up paragraph))
+    (while (and (setq up (org-element-property :parent up))
+		(not (memq (org-element-type up)
+			   '(center-block quote-block section)))))
+    (case (org-element-type up)
+      (center-block 'centered)
+      (quote-block 'quoted))))
+
 (defun org-odt--format-paragraph (paragraph contents default center quote)
   "Format paragraph according to given styles.
 PARAGRAPH is a paragraph type element.  CONTENTS is the
@@ -2839,19 +2850,19 @@ transcoded contents of that paragraph, as a string.  DEFAULT,
 CENTER and QUOTE are, respectively, style to use when paragraph
 belongs to no special environment, a center block, or a quote
 block."
-  (let* ((parent (org-export-get-parent paragraph))
-	 (parent-type (org-element-type parent))
-	 (style (case parent-type
-		  (quote-block quote)
-		  (center-block center)
-		  (t default))))
-    ;; 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 (eq (org-element-type parent) 'item)
-	       (eq paragraph (car (org-element-contents parent))))
-      (setq contents (concat (org-odt--checkbox parent) contents)))
-    (format "\n<text:p text:style-name=\"%s\">%s</text:p>" style contents)))
+  (format "\n<text:p text:style-name=\"%s\">%s</text:p>"
+	  (case (org-odt--paragraph-style paragraph)
+	    (quoted quote)
+	    (centered center)
+	    (otherwise default))
+	  ;; If PARAGRAPH is a leading paragraph in an item that has
+	  ;; a checkbox, splice checkbox and paragraph contents
+	  ;; together.
+	  (concat (let ((parent (org-element-property :parent paragraph)))
+		    (and (eq (org-element-type parent) 'item)
+			 (not (org-export-get-previous-element paragraph info))
+			 (org-odt--checkbox parent)))
+		  contents)))
 
 (defun org-odt-paragraph (paragraph contents info)
   "Transcode a PARAGRAPH element from Org to ODT.