Automatically creating endnotes from a plain ASCII document in LibreOffice Writer

I’m trying to create PDF documents (using LibreOffice) from several plain ASCII files which have endnotes entered as plain text. So, for instance, A sentence might say “So and so(3)” and then at the bottom of the document, it will say (3) with whatever endnote is for that particular passage.

Anyway, I need to convert those to actual endnotes in LibreOffice, so I’ve just been doing a Search for “(1)” and then deleting it, and clicking Insert → Footnote/Endnote, and repeating the process over and over again. I’m just wondering if there’s any easy way to do this, without having to do it manually. I’ve looked into creating a macro for this, but I don’t know enough about the scripting language to do that.

Hi @Arlo1,

I can imagine a few different ways one could go about automating the creation of these endnotes, but depending upon the size of your text, it might just be worth it to perform the operation by hand.

Automation inside LO can be trickier than working with text files directly. One possibility might be to create a new ODF document and insert the text body and 2-3 endnotes as links. Once the document is saved, the file may be decompressed and you should be able to find where in the document the endnotes are located.

You might be able to figure out how to insert new endnotes in the XML document directly, and then automate the process of linking the references in the text body to a new endnote.