Hello,

Rob Stewart <robstewar...@gmail.com> writes:

> And just as soon as I send this email, I find the answer:

[num] syntax for footnotes is indeed a pain.  

However, the solution below is really a kludge because some parts of Org
(or external libraries) could hard-code it anyway.

> (setq org-footnote-re
>       (concat "\\[\\(?:"
>           ;; Match inline footnotes.
>           (org-re "fn:\\([-_[:word:]]+\\)?:\\|")
>           ;; Match other footnotes.
>           ;; "\\(?:\\([0-9]+\\)\\]\\)\\|"
>           (org-re "\\(fn:[-_[:word:]]+\\)")
>           "\\)"))
>
> (setq org-footnote-definition-re
>       (org-re "^\\[\\(fn:[-_[:word:]]+\\)\\]"))
>
> From http://stackoverflow.com/a/25342297/1526266 .

>From an export perspective, you can turn these footnotes back into
regular text at the parse tree level:

--8<---------------cut here---------------start------------->8---
(defun my-ignore-false-footnotes (ast backend info)
  (org-element-map ast 'footnote-reference
    (lambda (f)
      (let ((label (org-element-property :label f)))
        (when (org-string-match-p "\\`[0-9]+\\'" label)
          (org-element-set-element
           f
           (concat "[" label "]"
                   (make-string (org-element-property :post-blank f) ?\s)))))))
  ast)

(add-to-list org-export-filter-parse-tree-functions #'my-ignore-false-footnotes)
--8<---------------cut here---------------end--------------->8---


Regards,

-- 
Nicolas Goaziou

Reply via email to