瀏覽代碼

org-e-html/org-e-odt: Handle links to headlines created with C-c C-l

Jambunathan K 12 年之前
父節點
當前提交
14b093275f
共有 2 個文件被更改,包括 33 次插入26 次删除
  1. 16 14
      contrib/lisp/org-e-html.el
  2. 17 12
      contrib/lisp/org-e-odt.el

+ 16 - 14
contrib/lisp/org-e-html.el

@@ -2548,21 +2548,23 @@ INFO is a plist holding contextual information.  See
 				       (org-export-get-headline-number
 					destination info) "-")))
 		   (t (error "Shouldn't reach here"))))
+		 ;; What description to use?
 		 (desc
-		  ;; What description to use?
-		  (cond
-		   ;; Case 1: Link already has a description.  Use it.
-		   (desc desc)
-		   ;; Case 2: Link has no description and headline is
-		   ;; numbered. Use the section number.
-		   ((org-export-numbered-headline-p destination info)
-		    (mapconcat 'number-to-string
-			       (org-export-get-headline-number
-				destination info) "."))
-		   ;; Case 3: Link has no description and headline is
-		   ;; un-numbered.  Use the headline title.
-		   (t (org-export-data
-		       (org-element-property :title destination) info)))))
+		  ;; Case 1: Headline is numbered and LINK has no
+		  ;; description or LINK's description matches
+		  ;; headline's title.  Display section number.
+		  (if (and (org-export-numbered-headline-p destination info)
+			   (or (not desc)
+			       (string= desc (org-element-property
+					      :raw-value destination))))
+		      (mapconcat 'number-to-string
+				 (org-export-get-headline-number
+				  destination info) ".")
+		    ;; Case 2: Either the headline is un-numbered or
+		    ;; LINK has a custom description.  Display LINK's
+		    ;; description or headline's title.
+		    (or desc (org-export-data (org-element-property
+					       :title destination) info)))))
 	     (format "<a href=\"#%s\"%s>%s</a>"
 		     (org-solidify-link-text href) attributes desc)))
           ;; Fuzzy link points to a target.  Do as above.

+ 17 - 12
contrib/lisp/org-e-odt.el

@@ -368,7 +368,7 @@ new entry in `org-e-odt-automatic-styles'.  Return (OBJECT-NAME
       (when (numberp desc)
 	(setq desc (format "%d" desc) xref-format "number"))
       (when (listp desc)
-	(setq desc (mapconcat 'identity desc ".") xref-format "chapter"))
+	(setq desc (mapconcat 'number-to-string desc ".") xref-format "chapter"))
       (setq href (concat org-e-odt-bookmark-prefix href))
       (org-e-odt-format-tags-simple
        '("<text:bookmark-ref text:reference-format=\"%s\" text:ref-name=\"%s\">" .
@@ -3321,21 +3321,26 @@ INFO is a plist holding contextual information.  See
 	    'italic))
 	  ;; Fuzzy link points to an invisible target.
 	  (keyword nil)
-	  ;; LINK points to an headline.  If headlines are numbered
-	  ;; and the link has no description, display headline's
-	  ;; number.  Otherwise, display description or headline's
-	  ;; title.
+	  ;; LINK points to an headline.  Check if LINK should display
+	  ;; section numbers.
 	  (headline
 	   (let* ((headline-no (org-export-get-headline-number destination info))
 		  (label (format "sec-%s" (mapconcat 'number-to-string
 						     headline-no "-")))
-		  (section-no (mapconcat 'number-to-string headline-no ".")))
-	     (setq desc
-		   (cond
-		    (desc desc)
-		    ((plist-get info :section-numbers) section-no)
-		    (t (org-export-data
-			(org-element-property :title destination) info))))
+		  (desc
+		   ;; Case 1: Headline is numbered and LINK has no
+		   ;; description or LINK's description matches
+		   ;; headline's title.  Display section number.
+		   (if (and (org-export-numbered-headline-p destination info)
+			    (or (not desc)
+				(string= desc (org-element-property
+					       :raw-value destination))))
+		       headline-no
+		     ;; Case 2: Either the headline is un-numbered or
+		     ;; LINK has a custom description.  Display LINK's
+		     ;; description or headline's title.
+		     (or desc (org-export-data (org-element-property
+						:title destination) info)))))
 	     (org-e-odt-format-internal-link desc label)))
 	  ;; Fuzzy link points to a target.  Do as above.
 	  (otherwise