소스 검색

Footnotes: Allow validated XHTML with multiple references to one note

Org-mode allows multiple references to the same footnote.  However,
the HTML exporter cannot use the same name for all these references,
because names have to be unique.  This patch appends numbers to
footnote reference names, to make sure they remain unique.

The dark side of this patch means that from the footnote definition,
there is only a single link, to the first reference of the note.
However, in a browser you can always press BACK to go back after
jumping to a footnote definition.
Carsten Dominik 17 년 전
부모
커밋
572caeb155
1개의 변경된 파일10개의 추가작업 그리고 4개의 파일을 삭제
  1. 10 4
      lisp/org-exp.el

+ 10 - 4
lisp/org-exp.el

@@ -3181,7 +3181,7 @@ PUB-DIR is set, use this as the publishing directory."
 	 ind item-type starter didclose
 	 ind item-type starter didclose
 	 rpl path attr desc descp desc1 desc2 link
 	 rpl path attr desc descp desc1 desc2 link
 	 snumber fnc item-tag
 	 snumber fnc item-tag
-	 footnotes
+	 footnotes footref-seen
 	 )
 	 )
 
 
     (let ((inhibit-read-only t))
     (let ((inhibit-read-only t))
@@ -3583,12 +3583,18 @@ lang=\"%s\" xml:lang=\"%s\">
 	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
 	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
 	      (if (get-text-property (match-beginning 2) 'org-protected line)
 	      (if (get-text-property (match-beginning 2) 'org-protected line)
 		  (setq start (match-end 2))
 		  (setq start (match-end 2))
-		(let ((n (match-string 2 line)))
+		(let ((n (match-string 2 line)) extra a)
+		  (if (setq a (assoc n footref-seen))
+		      (progn
+			(setcdr a (1+ (cdr a)))
+			(setq extra (format ".%d" (cdr a))))
+		    (setq extra "")
+		    (push (cons n 1) footref-seen))
 		  (setq line
 		  (setq line
 			(replace-match
 			(replace-match
 			 (format
 			 (format
-			  "%s<sup><a class=\"footref\" name=\"fnr.%s\" href=\"#fn.%s\">%s</a></sup>"
-			  (match-string 1 line) n n n)
+			  "%s<sup><a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a></sup>"
+			  (match-string 1 line) n extra n n)
 			 t t line))))))
 			 t t line))))))
 
 
 	  (cond
 	  (cond