Browse Source

Bugfix: correctly convert the footnote reference.

Bastien Guerry 15 years ago
parent
commit
01d84ed000
2 changed files with 14 additions and 9 deletions
  1. 3 0
      lisp/ChangeLog
  2. 11 9
      lisp/org-html.el

+ 3 - 0
lisp/ChangeLog

@@ -1,5 +1,8 @@
 2009-07-27  Bastien Guerry  <bzg@altern.org>
 
+	* org-html.el (org-export-as-html): Bugfix: correctly convert the
+	footnote reference before the footnote itself.
+
 	* org.el (org-toggle-heading): Bugfix: correctly convert list
 	items before the first headline.
 

+ 11 - 9
lisp/org-html.el

@@ -321,7 +321,7 @@ starting from 1 in the first header line.  For example
 
 will give even lines the class \"tr-even\" and odd lines the class \"tr-odd\"."
   :group 'org-export-tables
-  :type '(cons 
+  :type '(cons
 	  (choice :tag "Opening tag"
 		  (string :tag "Specify")
 		  (sexp))
@@ -1168,7 +1168,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	  ;; Does this contain a reference to a footnote?
 	  (when org-export-with-footnotes
 	    (setq start 0)
-	    (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)
 		  (setq start (match-end 2))
 		(let ((n (match-string 2 line)) extra a)
@@ -1181,9 +1181,9 @@ lang=\"%s\" xml:lang=\"%s\">
 		  (setq line
 			(replace-match
 			 (format
-			  (concat "%s"
-				  (format org-export-html-footnote-format
-					  "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"))
+			  (concat (if (match-string 1 line) "%s" "")
+			 	  (format org-export-html-footnote-format
+			 		  "<a class=\"footref\" name=\"fnr.%s%s\" href=\"#fn.%s\">%s</a>"))
 			  (match-string 1 line) n extra n n)
 			 t t line))))))
 
@@ -1331,8 +1331,10 @@ lang=\"%s\" xml:lang=\"%s\">
 		(let ((n (match-string 1 line)))
 		  (setq org-par-open t
 			line (replace-match
-			      (format "<p class=\"footnote\"><sup><a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a></sup>" n n n) t t line)))))
-
+			      (format "<p class=\"footnote\">"
+				      (format org-export-html-footnote-format
+					      "<a class=\"footnum\" name=\"fn.%s\" href=\"#fnr.%s\">%s</a>")
+				      n n n) t t line)))))
 	    ;; Check if the line break needs to be conserved
 	    (cond
 	     ((string-match "\\\\\\\\[ \t]*$" line)
@@ -1378,7 +1380,7 @@ lang=\"%s\" xml:lang=\"%s\">
 	  (replace-match "" t t)))
       (when footnotes
 	(insert (format org-export-html-footnotes-section
-			(or (nth 4 lang-words) "Footnotes")
+			(nth 4 lang-words)
 			(mapconcat 'identity (nreverse footnotes) "\n"))
 		"\n"))
       (let ((bib (org-export-html-get-bibliography)))
@@ -1467,7 +1469,7 @@ lang=\"%s\" xml:lang=\"%s\">
 
 (defun org-export-html-insert-plist-item (plist key &rest args)
   (let ((item (plist-get plist key)))
-    (cond ((functionp item) 
+    (cond ((functionp item)
            (apply item args))
           (item
            (insert item)))))