emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Nicolas Goaziou <mail@nicolasgoaziou.fr>
To: Rob Stewart <robstewart57@gmail.com>
Cc: emacs-orgmode@gnu.org
Subject: Re: Fwd: Don't treat [n] as a footnote, and export "[n]"
Date: Thu, 23 Apr 2015 21:40:39 +0200	[thread overview]
Message-ID: <87lhhi1vm0.fsf@nicolasgoaziou.fr> (raw)
In-Reply-To: <CA+ZOas+HcDEJaO7hZqHnwtC0JhdRSkOAg0+shUB8PggSVfvdFg@mail.gmail.com> (Rob Stewart's message of "Thu, 23 Apr 2015 20:27:36 +0100")

Hello,

Rob Stewart <robstewart57@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	other threads:[~2015-04-23 19:39 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-23 19:10 Don't treat [n] as a footnote, and export "[n]" Rob Stewart
2015-04-23 19:27 ` Fwd: " Rob Stewart
2015-04-23 19:40   ` Nicolas Goaziou [this message]
2015-04-23 19:49     ` Rob Stewart
2015-04-23 19:53       ` Nicolas Goaziou
2015-04-23 20:03         ` Rob Stewart

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhhi1vm0.fsf@nicolasgoaziou.fr \
    --to=mail@nicolasgoaziou.fr \
    --cc=emacs-orgmode@gnu.org \
    --cc=robstewart57@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).