浏览代码

org-odt.el: Honor short caption for table, figure etc

* lisp/org-odt.el (org-odt-begin-table)
(org-export-odt-format-formula, org-export-odt-format-image)
(org-odt-format-entity): Handle short caption.
* lisp/org-lparse.el (org-lparse-insert-org-table)
(org-lparse-insert-list-table, org-lparse-insert-table-table):
Ditto.

Handle short caption for tables, figures and formulae.
  #+CAPTION: [Caption for index entry]{Regular caption.}

Fix for bug
http://lists.gnu.org/archive/html/emacs-orgmode/2012-03/msg01169.html
Jambunathan K 13 年之前
父节点
当前提交
67694297fa
共有 2 个文件被更改,包括 41 次插入11 次删除
  1. 12 4
      lisp/org-lparse.el
  2. 29 7
      lisp/org-odt.el

+ 12 - 4
lisp/org-lparse.el

@@ -1222,6 +1222,11 @@ for formatting.  This is required for the DocBook exporter."
     (setq lines (org-table-clean-before-export lines)))
   (let* ((caption (org-find-text-property-in-string 'org-caption (car lines)))
 	 (caption (and caption (org-xml-encode-org-text caption)))
+	 (short-caption (org-find-text-property-in-string
+			 'org-caption-shortn (car lines)))
+	 (short-caption (or short-caption caption))
+	 (short-caption (and short-caption
+			     (org-xml-encode-org-text short-caption)))
 	 (label (org-find-text-property-in-string 'org-label (car lines)))
 	 (org-lparse-table-colalign-info (org-lparse-table-get-colalign-info lines))
 	 (attributes (org-find-text-property-in-string 'org-attributes
@@ -1232,11 +1237,13 @@ for formatting.  This is required for the DocBook exporter."
 			       (cdr lines))))))
     (setq lines (org-lparse-org-table-to-list-table lines splice))
     (org-lparse-insert-list-table
-     lines splice caption label attributes head org-lparse-table-colalign-info)))
+     lines splice caption label attributes head org-lparse-table-colalign-info
+     short-caption)))
 
 (defun org-lparse-insert-list-table (lines &optional splice
 					      caption label attributes head
-					      org-lparse-table-colalign-info)
+					      org-lparse-table-colalign-info
+					      short-caption)
   (or (featurep 'org-table)		; required for
       (require 'org-table))		; `org-table-number-regexp'
   (let* ((org-lparse-table-rownum -1) org-lparse-table-ncols i (cnt 0)
@@ -1256,7 +1263,7 @@ for formatting.  This is required for the DocBook exporter."
 	(insert (org-lparse-format-table-row line) "\n")))
      (t
       (setq org-lparse-table-is-styled t)
-      (org-lparse-begin 'TABLE caption label attributes)
+      (org-lparse-begin 'TABLE caption label attributes short-caption)
       (setq org-lparse-table-begin-marker (point))
       (org-lparse-begin-table-rowgroup head)
       (while (setq line (pop lines))
@@ -1287,13 +1294,14 @@ But it has the disadvantage, that no cell- or row-spanning is allowed."
 	     (org-lparse-table-cur-rowgrp-is-hdr
 	      org-export-highlight-first-table-line)
 	     (caption nil)
+	     (short-caption nil)
 	     (attributes nil)
 	     (label nil)
 	     (org-lparse-table-style 'table-table)
 	     (org-lparse-table-is-styled nil)
 	     fields org-lparse-table-ncols i (org-lparse-table-rownum -1)
 	     (empty (org-lparse-format 'SPACES 1)))
-    (org-lparse-begin 'TABLE caption label attributes)
+    (org-lparse-begin 'TABLE caption label attributes short-caption)
     (while (setq line (pop lines))
       (cond
        ((string-match "^[ \t]*\\+-" line)

+ 29 - 7
lisp/org-odt.el

@@ -987,7 +987,7 @@ new entry in `org-odt-automatic-styles'.  Return (OBJECT-NAME
     (cons object-name style-name)))
 
 (defvar org-odt-table-indentedp nil)
-(defun org-odt-begin-table (caption label attributes)
+(defun org-odt-begin-table (caption label attributes short-caption)
   (setq org-odt-table-indentedp (not (null org-lparse-list-stack)))
   (when org-odt-table-indentedp
     ;; Within the Org file, the table is appearing within a list item.
@@ -1006,11 +1006,12 @@ new entry in `org-odt-automatic-styles'.  Return (OBJECT-NAME
     (insert
      (org-odt-format-stylized-paragraph
       'table (org-odt-format-entity-caption label caption "__Table__"))))
-  (let ((name-and-style (org-odt-add-automatic-style "Table" attributes)))
+  (let ((automatic-name (org-odt-add-automatic-style "Table" attributes)))
     (org-lparse-insert-tag
      "<table:table table:name=\"%s\" table:style-name=\"%s\">"
-     (car name-and-style) (or (nth 1 org-odt-table-style-spec)
-			      (cdr name-and-style) "OrgTable")))
+     (or short-caption (car automatic-name))
+     (or (nth 1 org-odt-table-style-spec)
+	 (cdr automatic-name) "OrgTable")))
   (setq org-lparse-table-begin-marker (point)))
 
 (defvar org-lparse-table-colalign-info)
@@ -1552,7 +1553,12 @@ See `org-odt-add-label-definition' and
 (defun org-export-odt-format-formula (src href)
   (save-match-data
     (let* ((caption (org-find-text-property-in-string 'org-caption src))
+	   (short-caption
+	    (or (org-find-text-property-in-string 'org-caption-shortn src)
+		caption))
 	   (caption (and caption (org-xml-format-desc caption)))
+	   (short-caption (and short-caption
+			       (org-xml-format-desc short-caption)))
 	   (label (org-find-text-property-in-string 'org-label src))
 	   (latex-frag (org-find-text-property-in-string 'org-latex-src src))
 	   (embed-as (or (and latex-frag
@@ -1572,7 +1578,8 @@ See `org-odt-add-label-definition' and
 	 `((,(org-odt-format-entity
 	      (if (not (or caption label)) "DisplayFormula"
 		"CaptionedDisplayFormula")
-	      href width height :caption caption :label label)
+	      href width height :caption caption :label label
+	      :short-caption short-caption)
 	    ,(if (not (or caption label)) ""
 	       (let* ((label-props (car org-odt-entity-labels-alist)))
 		 (setcar (last label-props) "math-label")
@@ -1800,7 +1807,12 @@ ATTR is a string of other attributes of the a element."
   "Create image tag with source and attributes."
   (save-match-data
     (let* ((caption (org-find-text-property-in-string 'org-caption src))
+	   (short-caption
+	    (or (org-find-text-property-in-string 'org-caption-shortn src)
+		caption))
 	   (caption (and caption (org-xml-format-desc caption)))
+	   (short-caption (and short-caption
+			       (org-xml-format-desc short-caption)))
 	   (attr (org-find-text-property-in-string 'org-attributes src))
 	   (label (org-find-text-property-in-string 'org-label src))
 	   (latex-frag (org-find-text-property-in-string
@@ -1838,6 +1850,7 @@ ATTR is a string of other attributes of the a element."
 	(org-odt-format-entity
 	 frame-style-handle href width height
 	 :caption caption :label label :category category
+	 :short-caption short-caption
 	 :user-frame-params user-frame-params)))))
 
 (defun org-odt-format-object-description (title description)
@@ -1916,7 +1929,7 @@ ATTR is a string of other attributes of the a element."
 
 (defun* org-odt-format-entity (entity href width height
 				      &key caption label category
-				      user-frame-params)
+				      user-frame-params short-caption)
   (let* ((entity-style (assoc-string entity org-odt-entity-frame-styles t))
 	 default-frame-params frame-params)
     (cond
@@ -1934,7 +1947,16 @@ ATTR is a string of other attributes of the a element."
 	      'illustration
 	      (concat
 	       (apply 'org-odt-format-frame href width height
-		      (nth 2 entity-style))
+		      (let ((entity-style-1 (copy-sequence
+					     (nth 2 entity-style))))
+			(setcar (cdr entity-style-1)
+				(concat
+				 (cadr entity-style-1)
+				 (and short-caption
+				      (format " draw:name=\"%s\" "
+					      short-caption))))
+
+			entity-style-1))
 	       (org-odt-format-entity-caption
 		label caption (or category (nth 1 entity-style)))))
 	     width height frame-params)))))