Bläddra i källkod

Add properties to footnotes during export

* lisp/org-footnote.el (org-footnote-normalize): add `org-footnote'
  property to footnote markers when preparing for exportation.
* lisp/org-html.el (org-export-as-html): read new property to decide
  when to export a footnote.
* lisp/org-docbook.el (org-export-as-docbook): read new property to
  decide when to export a footnote.
* lisp/org-latex.el (org-export-latex-preprocess): ensure footnote at
  column 0 cannot end a list containing it by adding
  `original-indentation' property to it.
Nicolas Goaziou 13 år sedan
förälder
incheckning
30944f228e
4 ändrade filer med 19 tillägg och 5 borttagningar
  1. 4 1
      lisp/org-docbook.el
  2. 6 1
      lisp/org-footnote.el
  3. 4 1
      lisp/org-html.el
  4. 5 2
      lisp/org-latex.el

+ 4 - 1
lisp/org-docbook.el

@@ -936,7 +936,10 @@ publishing directory."
 	  (when org-export-with-footnotes
 	    (setq start 0)
 	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
-	      (if (get-text-property (match-beginning 2) 'org-protected line)
+	      ;; Discard protected matches not clearly identified as
+	      ;; footnote markers.
+	      (if (or (get-text-property (match-beginning 2) 'org-protected line)
+		      (not (get-text-property (match-beginning 2) 'org-footnote line)))
 		  (setq start (match-end 2))
 		(let* ((num (match-string 2 line))
 		       (footnote-def (assoc num footnote-list)))

+ 6 - 1
lisp/org-footnote.el

@@ -532,11 +532,16 @@ Additional note on `org-footnote-insert-pos-for-preprocessor':
 	  ;; Replace footnote reference with [MARKER]. Maybe fill
 	  ;; paragraph once done. If SORT-ONLY is non-nil, only move
 	  ;; to the end of reference found to avoid matching it twice.
+	  ;; If PRE-PROCESS-P isn't nil, also add `org-footnote'
+	  ;; property to it, so it can be easily recognized by
+	  ;; exporters.
 	  (if sort-only
 	      (goto-char (nth 2 ref))
 	    (delete-region (nth 1 ref) (nth 2 ref))
 	    (goto-char (nth 1 ref))
-	    (insert (format "[%d]" marker))
+	    (let ((new-ref (format "[%d]" marker)))
+	      (when pre-process-p (org-add-props new-ref '(org-footnote t)))
+	      (insert new-ref))
 	    (and inlinep
 		 org-footnote-fill-after-inline-note-extraction
 		 (org-fill-paragraph)))

+ 4 - 1
lisp/org-html.el

@@ -1582,7 +1582,10 @@ lang=\"%s\" xml:lang=\"%s\">
 	  (when org-export-with-footnotes
 	    (setq start 0)
 	    (while (string-match "\\([^* \t].*?\\)\\[\\([0-9]+\\)\\]" line start)
-	      (if (get-text-property (match-beginning 2) 'org-protected line)
+	      ;; Discard protected matches not clearly identified as
+	      ;; footnote markers.
+	      (if (or (get-text-property (match-beginning 2) 'org-protected line)
+		      (not (get-text-property (match-beginning 2) 'org-footnote line)))
 		  (setq start (match-end 2))
 		(let ((n (match-string 2 line)) extra a)
 		  (if (setq a (assoc n footref-seen))

+ 5 - 2
lisp/org-latex.el

@@ -2456,8 +2456,11 @@ The conversion is made depending of STRING-BEFORE and STRING-AFTER."
 					    (and next (= (nth 1 next) (nth 2 ref)))))
 			  org-export-latex-footnote-separator ""))))
 	    (when (org-on-heading-p)
-	      (setq fnote
-		    (concat (org-export-latex-protect-string "\\protect") fnote)))
+	      (setq fnote (concat (org-export-latex-protect-string"\\protect")
+				  fnote)))
+	    ;; Ensure a footnote at column 0 cannot end a list
+	    ;; containing it.
+	    (put-text-property 0 (length fnote) 'original-indentation 1000 fnote)
 	    ;; Replace footnote reference with FNOTE and, maybe, SEP.
 	    ;; `save-excursion' is required if there are two footnotes
 	    ;; in a row. In that case, point would be left at the