Browse Source

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.
Nicolas Goaziou 12 years ago
parent
commit
e5a249b327
2 changed files with 19 additions and 5 deletions
  1. 13 5
      lisp/org-element.el
  2. 6 0
      lisp/ox.el

+ 13 - 5
lisp/org-element.el

@@ -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',
-`:pre-blank', `:hiddenp', `:contents-begin' and `:contents-end',
-`:level', `:priority', `:tags', `:todo-keyword',`:todo-type',
-`:scheduled', `:deadline', `:closed', `:quotedp', `:archivedp',
-`:commentedp' and `:footnote-section-p' keywords.
+containing `:raw-value', `:title', `:optional-title', `:begin',
+`:end', `:pre-blank', `:hiddenp', `:contents-begin' and
+`:contents-end', `:level', `:priority', `:tags',
+`:todo-keyword',`:todo-type', `:scheduled', `:deadline',
+`: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

+ 6 - 0
lisp/ox.el

@@ -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."