Browse Source

ox-ascii: Small fix to items that do not start with a paragraph

* lisp/ox-ascii.el (org-ascii-item): Use better heuristics to
  determine if contents should follow bullet or start a new line.

Contents follow bullet when the first contributing line is
a paragraph.  As a consequence, the following snippet

    -
      #+html: ...
      This is a paragraph.

is exported as

    - This is a paragraph.

instead of

    -
      This is a paragraph.

previously.
Nicolas Goaziou 2 months ago
parent
commit
0880fc580e
1 changed files with 12 additions and 3 deletions
  1. 12 3
      lisp/ox-ascii.el

+ 12 - 3
lisp/ox-ascii.el

@@ -1485,9 +1485,18 @@ contextual information."
      ;; already taken care of at the paragraph level so they don't
      ;; interfere with indentation.
      (let ((contents (org-ascii--indent-string contents indentation)))
-       (if (and (eq (org-element-type (car (org-element-contents item)))
-		    'paragraph)
-		(not (eq list-type 'descriptive)))
+       ;; Determine if contents should follow the bullet or start
+       ;; a new line.  Do the former when the first contributing
+       ;; element to contents is a paragraph.  In descriptive lists
+       ;; however, contents always start a new line.
+       (if (and (not (eq list-type 'descriptive))
+		(org-string-nw-p contents)
+		(eq 'paragraph
+		    (org-element-type
+		     (cl-some (lambda (e)
+				(and (org-string-nw-p (org-export-data e info))
+				     e))
+			      (org-element-contents item)))))
 	   (org-trim contents)
 	 (concat "\n" contents))))))