Parcourir la source

Merge branch 'maint'

Nicolas Goaziou il y a 10 ans
Parent
commit
010d105b04
1 fichiers modifiés avec 24 ajouts et 13 suppressions
  1. 24 13
      lisp/ox-odt.el

+ 24 - 13
lisp/ox-odt.el

@@ -2864,6 +2864,17 @@ information."
 
 ;;;; 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
@@ -2871,19 +2882,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.