浏览代码

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 年之前
父节点
当前提交
e5a249b327
共有 2 个文件被更改,包括 19 次插入5 次删除
  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.
 
 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,
 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)
 		    time-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
 	 headline :title
 	 (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))))
       "???"))
 
+(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)
   "Non-nil when HEADLINE is the first sibling in its sub-tree.
 INFO is a plist used as a communication channel."