Move footnotes after punctuation

Hello.

In some style guides, the footnote number is placed before punctuation marks, and in some, it is placed after. Generally, I have chosen the latter format and recommend it. So, if a text is formatted in the first way and I want to move the footnote number after the punctuation marks, how can I do it with regular expressions?

PS:
Version: 24.2.7.2 (X86_64) / LibreOffice Community
Build ID: 420(Build:2)
CPU threads: 2; OS: Linux 6.8; UI render: default; VCL: gtk3
Locale: fa-IR (en_US.UTF-8); UI: en-US
Ubuntu package version: 4:24.2.7-0ubuntu0.24.04.2
Calc: threaded

I am afraid you can’t do it with Writer regexp because there is no “designator” for a note.

If you’re brave, save your document as a .fodt and use a macro generator to move the punctuation.

All note information is contained in a <text:note … > … </text:note> XML element.

Your goal is to match such an element and capture it into a variable (group). Follow it with a set containing the punctuations like [.,;?!]. The pattern is then

(<text:note .+?/text:note>)([.,;?!])

Replacement action is simply $2$1.


This is a quick suggestion without testing. Depending on the sophistication of the macro generator, you may need to escape < or tune the “swallowing” sub-pattern .+?. Experiment.


PS1: when asking here, always mention OS name, LO version and save format.

PS2: in some languages, countries and typographical traditions, a punctuation may be preceded by a space. Visually, this would suggest the note is relative to the punctuation, not the word preceding it.

This allows for two nuances of notes:

  • the anchor is attached to the word: note relates to this word
  • the anchor is attached to the punctuation: the note relates to the full sentence or paragraph

How do the guides (particularly those use in North America) translate the difference in significance?