Function: org-element-headline-parser
org-element-headline-parser is a byte-compiled function defined in
org-element.el.gz.
Signature
(org-element-headline-parser &optional _ RAW-SECONDARY-P)
Documentation
Parse a headline.
Return a new syntax node of headline type containing :raw-value,
:title, :begin, :end, :pre-blank, :contents-begin and
:contents-end, :level, :priority, :tags, :todo-keyword,
:todo-type, :scheduled, :deadline, :closed, :archivedp,
:commentedp :footnote-section-p, :post-blank and
:post-affiliated properties.
The plist also contains any property set in the property drawer, with its name in upper cases and colons added at the beginning (e.g., :CUSTOM_ID).
When RAW-SECONDARY-P is non-nil, headline's title will not be parsed as a secondary string, but as a plain string instead.
Assume point is at beginning of the headline.
Source Code
;; Defined in /usr/src/emacs/lisp/org/org-element.el.gz
(defun org-element-headline-parser (&optional _ raw-secondary-p)
"Parse a headline.
Return a new syntax node of `headline' type containing `:raw-value',
`:title', `:begin', `:end', `:pre-blank', `:contents-begin' and
`:contents-end', `:level', `:priority', `:tags', `:todo-keyword',
`:todo-type', `:scheduled', `:deadline', `:closed', `:archivedp',
`:commentedp' `:footnote-section-p', `:post-blank' and
`:post-affiliated' properties.
The plist also contains any property set in the property drawer,
with its name in upper cases and colons added at the
beginning (e.g., `:CUSTOM_ID').
When RAW-SECONDARY-P is non-nil, headline's title will not be
parsed as a secondary string, but as a plain string instead.
Assume point is at beginning of the headline."
(save-excursion
(let* ((deferred-title-prop
(if raw-secondary-p
org-element--headline-parse-title-raw
org-element--headline-parse-title-parse))
(begin (point))
(true-level (skip-chars-forward "*"))
(end
(save-excursion
(if (re-search-forward (org-headline-re true-level) nil t)
(line-beginning-position)
(point-max))))
(contents-begin (save-excursion
(forward-line)
(skip-chars-forward " \r\t\n" end)
(and (/= (point) end) (line-beginning-position))))
(contents-end (and contents-begin end))
(robust-begin
;; If there is :pre-blank, we
;; need to be careful about
;; robust beginning.
(when contents-begin
(when (< (+ 2 contents-begin) contents-end)
(+ 2 contents-begin))))
(robust-end (and robust-begin end)))
(org-element-create
'headline
(list
:begin begin
:end end
:pre-blank
(if (not contents-begin) 0
(1- (count-lines begin contents-begin)))
:contents-begin contents-begin
:contents-end contents-end
:robust-begin robust-begin
:robust-end robust-end
:true-level true-level
:buffer (current-buffer)
:raw-value deferred-title-prop
:title deferred-title-prop
:level deferred-title-prop
:priority deferred-title-prop
:tags deferred-title-prop
:todo-keyword deferred-title-prop
:todo-type deferred-title-prop
:post-blank
(if contents-end
;; Trailing blank lines in org-data, headlines, and
;; sections belong to the containing elements.
0
(1- (count-lines begin end)))
:footnote-section-p deferred-title-prop
:archivedp deferred-title-prop
:commentedp deferred-title-prop
:post-affiliated begin
:secondary (alist-get
'headline
org-element-secondary-value-alist)
:deferred org-element--headline-deferred)))))