Function: org-element-item-parser

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

Signature

(org-element-item-parser _ STRUCT &optional RAW-SECONDARY-P)

Documentation

Parse an item.

STRUCT is the structure of the plain list.

Return a list whose CAR is item and CDR is a plist containing
:bullet, :begin, :end, :contents-begin, :contents-end,
:checkbox, :counter, :tag, :structure, :pre-blank,
:post-blank and :post-affiliated keywords.

When optional argument RAW-SECONDARY-P is non-nil, item's tag, if any, will not be parsed as a secondary string, but as a plain string instead.

Assume point is at the beginning of the item.

Source Code

;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
;;;; Item

(defun org-element-item-parser (_ struct &optional raw-secondary-p)
  "Parse an item.

STRUCT is the structure of the plain list.

Return a list whose CAR is `item' and CDR is a plist containing
`:bullet', `:begin', `:end', `:contents-begin', `:contents-end',
`:checkbox', `:counter', `:tag', `:structure', `:pre-blank',
`:post-blank' and `:post-affiliated' keywords.

When optional argument RAW-SECONDARY-P is non-nil, item's tag, if
any, will not be parsed as a secondary string, but as a plain
string instead.

Assume point is at the beginning of the item."
  (save-excursion
    (beginning-of-line)
    (looking-at org-list-full-item-re)
    (let* ((begin (point))
	   (bullet (match-string-no-properties 1))
	   (checkbox (let ((box (match-string 3)))
		       (cond ((equal "[ ]" box) 'off)
			     ((equal "[X]" box) 'on)
			     ((equal "[-]" box) 'trans))))
	   (counter (let ((c (match-string 2)))
		      (save-match-data
			(cond
			 ((not c) nil)
			 ((string-match "[A-Za-z]" c)
			  (- (string-to-char (upcase (match-string 0 c)))
			     64))
			 ((string-match "[0-9]+" c)
			  (string-to-number (match-string 0 c)))))))
	   (end (progn (goto-char (nth 6 (assq (point) struct)))
		       (if (bolp) (point) (line-beginning-position 2))))
	   (pre-blank 0)
	   (contents-begin
	    (progn
	      (goto-char
	       ;; Ignore tags in un-ordered lists: they are just
	       ;; a part of item's body.
	       (if (and (match-beginning 4)
			(save-match-data (string-match "[.)]" bullet)))
		   (match-beginning 4)
		 (match-end 0)))
	      (skip-chars-forward " \r\t\n" end)
	      (cond ((= (point) end) nil)
		    ;; If first line isn't empty, contents really
		    ;; start at the text after item's meta-data.
		    ((= (line-beginning-position) begin) (point))
		    (t
		     (setq pre-blank
			   (count-lines (line-beginning-position) begin))
		     (line-beginning-position)))))
	   (contents-end (and contents-begin
			      (progn (goto-char end)
				     (skip-chars-backward " \r\t\n")
				     (line-beginning-position 2))))
	   (item
	    (list 'item
		  (list :bullet bullet
			:begin begin
			:end end
			:contents-begin contents-begin
			:contents-end contents-end
			:checkbox checkbox
			:counter counter
			:structure struct
			:pre-blank pre-blank
			:post-blank (count-lines (or contents-end begin) end)
			:post-affiliated begin))))
      (org-element-put-property
       item :tag
       (let ((raw (org-list-get-tag begin struct)))
	 (when raw
	   (if raw-secondary-p raw
	     (org-element--parse-objects
	      (match-beginning 4) (match-end 4) nil
	      (org-element-restriction 'item)
	      item))))))))