org-element/ox: Introduce :optional-title property and an accessor

* lisp/org-element.el (org-element-headline-parser): Node
  property :OPTIONAL_TITLE: in a headline will be parsed and stored
  under :optional-title property.
* lisp/ox.el (org-export-get-optional-title): New function.
This commit is contained in:
Nicolas Goaziou 2013-02-23 21:33:03 +01:00
parent a1236b9606
commit e5a249b327
2 changed files with 19 additions and 5 deletions

View File

@ -729,11 +729,12 @@ CONTENTS is the contents of the footnote-definition."
"Parse a headline. "Parse a headline.
Return a list whose CAR is `headline' and CDR is a plist Return a list whose CAR is `headline' and CDR is a plist
containing `:raw-value', `:title', `:begin', `:end', containing `:raw-value', `:title', `:optional-title', `:begin',
`:pre-blank', `:hiddenp', `:contents-begin' and `:contents-end', `:end', `:pre-blank', `:hiddenp', `:contents-begin' and
`:level', `:priority', `:tags', `:todo-keyword',`:todo-type', `:contents-end', `:level', `:priority', `:tags',
`:scheduled', `:deadline', `:closed', `:quotedp', `:archivedp', `:todo-keyword',`:todo-type', `:scheduled', `:deadline',
`:commentedp' and `:footnote-section-p' keywords. `:closed', `:quotedp', `:archivedp', `:commentedp' and
`:footnote-section-p' keywords.
The plist also contains any property set in the property drawer, The plist also contains any property set in the property drawer,
with its name in upper cases and colons added at the with its name in upper cases and colons added at the
@ -847,6 +848,13 @@ Assume point is at beginning of the headline."
:quotedp quotedp) :quotedp quotedp)
time-props time-props
standard-props)))) standard-props))))
(let ((opt-title (org-element-property :OPTIONAL_TITLE headline)))
(when opt-title
(org-element-put-property
headline :optional-title
(if raw-secondary-p opt-title
(org-element-parse-secondary-string
opt-title (org-element-restriction 'headline) headline)))))
(org-element-put-property (org-element-put-property
headline :title headline :title
(if raw-secondary-p raw-value (if raw-secondary-p raw-value

View File

@ -3548,6 +3548,12 @@ fail, the fall-back value is \"???\"."
(and file (file-name-sans-extension (file-name-nondirectory file)))) (and file (file-name-sans-extension (file-name-nondirectory file))))
"???")) "???"))
(defun org-export-get-optional-title (headline info)
"Return optional title for HEADLINE, as a secondary string.
INFO is a plist used as a communication channel. If no such
title is defined, return nil."
(org-element-property :optional-title headline))
(defun org-export-first-sibling-p (headline info) (defun org-export-first-sibling-p (headline info)
"Non-nil when HEADLINE is the first sibling in its sub-tree. "Non-nil when HEADLINE is the first sibling in its sub-tree.
INFO is a plist used as a communication channel." INFO is a plist used as a communication channel."