Function: org-list--to-generic-item

org-list--to-generic-item is a byte-compiled function defined in org-list.el.gz.

Signature

(org-list--to-generic-item PARAMS)

Documentation

Return a transcoder for item elements.

PARAMS is a plist used to tweak the behavior of the transcoder.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-list.el.gz
(defun org-list--to-generic-item (params)
  "Return a transcoder for `item' elements.
PARAMS is a plist used to tweak the behavior of the transcoder."
  (let ((backend (plist-get params :backend))
	(istart (plist-get params :istart))
	(iend (plist-get params :iend))
	(isep (plist-get params :isep))
	(icount (plist-get params :icount))
	(ifmt (plist-get params :ifmt))
	(cboff (plist-get params :cboff))
	(cbon  (plist-get params :cbon))
	(cbtrans (plist-get params :cbtrans))
	(dtstart (plist-get params :dtstart))
	(dtend (plist-get params :dtend))
	(ddstart (plist-get params :ddstart))
	(ddend (plist-get params :ddend)))
    (lambda (item contents info)
      (let* ((type
	      (org-element-property :type (org-element-parent item)))
	     (tag (org-element-property :tag item))
	     (depth (org-list--depth item))
	     (separator (and (org-export-get-next-element item info)
			     (org-list--generic-eval isep type depth)))
	     (closing (pcase (org-list--generic-eval iend type depth)
			((or `nil "") "\n")
			((and (guard separator) s)
			 (if (equal (substring s -1) "\n") s (concat s "\n")))
			(s s))))
	;; When a closing line or a separator is provided, make sure
	;; its trailing newlines are taken into account when building
	;; output.  This is done by setting `:post-blank' property to
	;; the number of such lines in the last line to be added.
	(let ((last-string (or separator closing)))
	  (when last-string
	    (org-element-put-property
	     item
	     :post-blank
	     (max (1- (org-list--trailing-newlines last-string)) 0))))
	;; Build output.
	(concat
	 (let ((c (org-element-property :counter item)))
	   (if (and c icount) (org-list--generic-eval icount type depth c)
	     (org-list--generic-eval istart type depth)))
	 (let ((body
		(if (or istart iend icount ifmt cbon cboff cbtrans (not backend)
			(and (eq type 'descriptive)
			     (or dtstart dtend ddstart ddend)))
		    (concat
		     (pcase (org-element-property :checkbox item)
		       (`on cbon)
		       (`off cboff)
		       (`trans cbtrans))
		     (and tag
			  (concat dtstart
				  (if backend
				      (org-export-data-with-backend
				       tag backend info)
				    (org-element-interpret-data tag))
				  dtend))
		     (and tag ddstart)
		     (let ((contents
			    (if (= (length contents) 0) ""
			      (substring contents 0 -1))))
		       (if ifmt (org-list--generic-eval ifmt type contents)
			 contents))
		     (and tag ddend))
		  (org-export-with-backend backend item contents info))))
	   ;; Remove final newline.
	   (if (equal body "") ""
	     (substring (org-element-normalize-string body) 0 -1)))
	 closing
	 separator)))))