Function: org-element-item-interpreter

org-element-item-interpreter is a byte-compiled function defined in org-element.el.gz.

Signature

(org-element-item-interpreter ITEM CONTENTS)

Documentation

Interpret ITEM element as Org syntax.

CONTENTS is the contents of the element.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defun org-element-item-interpreter (item contents)
  "Interpret ITEM element as Org syntax.
CONTENTS is the contents of the element."
  (let ((tag (pcase (org-element-property :tag item)
	       (`nil nil)
	       (tag (format "%s :: " (org-element-interpret-data tag)))))
	(bullet
	 (org-list-bullet-string
	  (cond
	   ((not (string-match-p "[0-9a-zA-Z]"
				 (org-element-property :bullet item))) "- ")
	   ((eq org-plain-list-ordered-item-terminator ?\)) "1)")
	   (t "1.")))))
    (concat
     bullet
     (pcase (org-element-property :counter item)
       (`nil nil)
       (counter (format "[@%d] " counter)))
     (pcase (org-element-property :checkbox item)
       (`on "[X] ")
       (`off "[ ] ")
       (`trans "[-] ")
       (_ nil))
     tag
     (when contents
       (let* ((ind (make-string (if tag 5 (length bullet)) ?\s))
	      (pre-blank
	       (min (or (org-element-property :pre-blank item)
			;; 0 is specific to paragraphs at the
			;; beginning of the item, so we use 1 as
			;; a fall-back value, which is more universal.
			1)
		    ;; Lists ends after more than two consecutive
		    ;; empty lines: limit ourselves to 2 newline
		    ;; characters.
		    2))
	      (contents (replace-regexp-in-string
			 "\\(^\\)[ \t]*\\S-" ind contents nil nil 1)))
	 (if (= pre-blank 0) (org-trim contents)
	   (concat (make-string pre-blank ?\n) contents)))))))