瀏覽代碼

org-export: Add optional argument to `org-export-read-attribute'

* contrib/lisp/org-export.el (org-export-read-attribute): Add optional
  argument to `org-export-read-attribute'.
* contrib/lisp/org-e-ascii.el (org-e-ascii-horizontal-rule): Use
  additional argument.
Nicolas Goaziou 13 年之前
父節點
當前提交
1b64d9582e
共有 2 個文件被更改,包括 12 次插入14 次删除
  1. 2 10
      contrib/lisp/org-e-ascii.el
  2. 10 4
      contrib/lisp/org-export.el

+ 2 - 10
contrib/lisp/org-e-ascii.el

@@ -1100,16 +1100,8 @@ holding contextual information."
   "Transcode an HORIZONTAL-RULE  object from Org to ASCII.
 CONTENTS is nil.  INFO is a plist holding contextual
 information."
-  (let ((attr
-	 (read
-	  (format
-	   "(%s)"
-	   (mapconcat
-	    #'identity
-	    (org-element-property :attr_ascii horizontal-rule)
-	    " ")))))
-    (make-string (or (and (wholenump (plist-get attr :width))
-			  (plist-get attr :width))
+  (let ((width (org-export-read-attribte :attr_ascii horizontal-rule :width)))
+    (make-string (or (and (wholenump width) width)
 		     (org-e-ascii--current-text-width horizontal-rule info))
 		 (if (eq (plist-get info :ascii-charset) 'utf-8) ?― ?-))))
 

+ 10 - 4
contrib/lisp/org-export.el

@@ -2706,14 +2706,20 @@ file should have."
 ;;  as a plist.  It can be used to normalize affiliated keywords'
 ;;  syntax.
 
-(defun org-export-read-attribute (attribute element)
+(defun org-export-read-attribute (attribute element &optional property)
   "Turn ATTRIBUTE property from ELEMENT into a plist.
+
+When optional argument PROPERTY is non-nil, return the value of
+that property within attributes.
+
 This function assumes attributes are defined as \":keyword
 value\" pairs.  It is appropriate for `:attr_html' like
 properties."
-  (let ((value (org-element-property attribute element)))
-    (and value
-	 (read (format "(%s)" (mapconcat 'identity value " "))))))
+  (let ((attributes
+	 (let ((value (org-element-property attribute element)))
+	   (and value
+		(read (format "(%s)" (mapconcat 'identity value " ")))))))
+    (if property (plist-get attributes property) attributes)))
 
 
 ;;;; For Export Snippets