瀏覽代碼

Process link descriptions in HTML export like any content.

Link descriptions where so far exported literally.  However, really
they need to escape special characters and have TeX-like macros
interpreted and emphasis enabled just like any other text.

This patch makes sure link descriptions are passed through a new
filter, `org-export-html-format-desc' which does just that.

This fix is a follow-up to a report by Sebastian Rose.
Carsten Dominik 16 年之前
父節點
當前提交
15b4ae9038
共有 2 個文件被更改,包括 23 次插入5 次删除
  1. 3 0
      lisp/ChangeLog
  2. 20 5
      lisp/org-exp.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2008-11-03  Carsten Dominik  <dominik@science.uva.nl>
 
+	* org-exp.el (org-export-as-html): Fully process link descriptions.
+	(org-export-html-format-desc): New function.
+
 	* org-agenda.el (org-agenda-remove-marked-text): Bind variable
 	BEG.
 

+ 20 - 5
lisp/org-exp.el

@@ -3218,7 +3218,9 @@ lang=\"%s\" xml:lang=\"%s\">
 		     "<a href=\"#"
 		     (org-solidify-link-text
 		      (save-match-data (org-link-unescape path)) nil)
-		     "\"" attr ">" desc "</a>")))
+		     "\"" attr ">" 
+		     (org-export-html-format-desc desc)
+		     "</a>")))
 	     ((member type '("http" "https"))
 	      ;; standard URL, just check if we need to inline an image
 	      (if (and (or (eq t org-export-html-inline-images)
@@ -3229,13 +3231,16 @@ lang=\"%s\" xml:lang=\"%s\">
 		(setq rpl (concat "<a href=\"" 
 				  (org-export-html-format-href link)
 				  "\"" attr ">"
-				  desc "</a>"))))
+				  (org-export-html-format-desc desc)
+				  "</a>"))))
 	     ((member type '("ftp" "mailto" "news"))
 	      ;; standard URL
 	      (setq link (concat type ":" path))
 	      (setq rpl (concat "<a href=\""
 				(org-export-html-format-href link)
-				"\"" attr ">" desc "</a>")))
+				"\"" attr ">" 
+				(org-export-html-format-desc desc)
+				"</a>")))
 
 	     ((functionp (setq fnc (nth 2 (assoc type org-link-protocols))))
 	      ;; The link protocol has a function for format the link
@@ -3281,7 +3286,8 @@ lang=\"%s\" xml:lang=\"%s\">
 					    (not descp))))
 			      (concat "<img src=\"" thefile "\"" attr "/>")
 			    (concat "<a href=\"" thefile "\"" attr ">"
-				    desc "</a>")))
+				    (org-export-html-format-desc desc)
+				    "</a>")))
 		(if (not valid) (setq rpl desc))))
 
 	     (t
@@ -3557,6 +3563,13 @@ lang=\"%s\" xml:lang=\"%s\">
 	      s (replace-match "&amp;" t t s)))))
   s)
 
+(defun org-export-html-format-desc (s)
+  "Make sure the S is valid as a description in a link."
+  (if s
+      (save-match-data
+	(org-html-do-expand s))
+    s))
+
 (defvar org-table-colgroup-info nil)
 (defun org-format-table-ascii (lines)
   "Format a table for ascii export."
@@ -3913,7 +3926,9 @@ that uses these same face definitions."
     (while (string-match "<" s)
       (setq s (replace-match "&lt;" t t s)))
     (while (string-match ">" s)
-      (setq s (replace-match "&gt;" t t s))))
+      (setq s (replace-match "&gt;" t t s)))
+    (while (string-match "\"" s)
+      (setq s (replace-match "&quot;" t t s))))
   s)
 
 (defun org-export-cleanup-toc-line (s)