Function: org-element-citation-parser

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

Signature

(org-element-citation-parser)

Documentation

Parse citation object at point, if any.

When at a citation object, return a new syntax node of citation type containing :style, :prefix, :suffix, :begin, :end,
:contents-begin, :contents-end, and :post-blank properties.
Otherwise, return nil.

Assume point is at the beginning of the citation.

Source Code

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

(defun org-element-citation-parser ()
  "Parse citation object at point, if any.

When at a citation object, return a new syntax node of `citation' type
containing `:style', `:prefix', `:suffix', `:begin', `:end',
`:contents-begin', `:contents-end', and `:post-blank' properties.
Otherwise, return nil.

Assume point is at the beginning of the citation."
  (when (looking-at org-element-citation-prefix-re)
    (let* ((begin (point))
	   (style (and (match-end 1)
		       (org-element--get-cached-string
                        (match-string-no-properties 1))))
	   ;; Ignore blanks between cite type and prefix or key.
	   (start (match-end 0))
	   (closing (with-syntax-table org-element--pair-square-table
		      (ignore-errors (scan-lists begin 1 0)))))
      (save-excursion
	(when (and closing
		   (re-search-forward org-element-citation-key-re closing t))
	  ;; Find prefix, if any.
	  (let ((first-key-end (match-end 0))
		(types (org-element-restriction 'citation-reference))
                (cite
		 (org-element-create
                  'citation
		  (list :style style
			:begin begin
			:post-blank (progn
				      (goto-char closing)
				      (skip-chars-forward " \t"))
			:end (point)
                        :secondary (alist-get
                                    'citation
                                    org-element-secondary-value-alist)))))
	    ;; `:contents-begin' depends on the presence of
	    ;; a non-empty common prefix.
	    (goto-char first-key-end)
	    (if (not (search-backward ";" start t))
		(org-element-put-property cite :contents-begin start)
	      (when (< start (point))
		(org-element-put-property
                 cite :prefix
                 (org-element--parse-objects start (point) nil types cite)))
	      (forward-char)
	      (org-element-put-property cite :contents-begin (point)))
	    ;; `:contents-end' depends on the presence of a non-empty
	    ;; common suffix.
	    (goto-char (1- closing))
	    (skip-chars-backward " \r\t\n")
	    (let ((end (point)))
	      (if (or (not (search-backward ";" first-key-end t))
		      (re-search-forward org-element-citation-key-re end t))
		  (org-element-put-property cite :contents-end end)
                (forward-char)
		(when (< (point) end)
		  (org-element-put-property
                   cite :suffix
                   (org-element--parse-objects (point) end nil types cite)))
		(org-element-put-property cite :contents-end (point))))
	    cite))))))