I have a bunch of text files where the footnotes are in the following
format:

<----- START OF FILE  ----->
Nobis delectus adipisci nostrum vel. Consequuntur ducimus repellat
saepe. Itaque [1] et sit voluptate non sint. Ab labore sapiente voluptatem
ratione illum voluptatem reprehenderit. Corporis sint exercitationem
doloremque impedit possimus laboriosam [2] nesciunt. Ex enim tenetur aut
dolorem sequi et nihil.

Explicabo ea itaque beatae. Earum [3] tenetur voluptatem tempora commodi.
Porro quibusdam vel quia repudiandae corporis ducimus.

[1]
STUFF THAT REFERS TO ITAQUE.¹
[2]
STUFF EXT THAT REFERS TO LABORIOSAM.
[3]
STUFF THAT REFERS TO EARUM.
...
<----- END OF FILE ----->

The footnotes are at the end of each file and I need to grab/delete them
in sequence and move/substitute each footnote's contents to the spot
where the corresponding anchor lives in the body of the text.

After substitution the first paragraph looks like this:

Nobis delectus adipisci nostrum vel. Consequuntur ducimus repellat
saepe. Itaque^[STUFF THAT REFERS TO ITAQUE.]² et sit voluptate non sint.
Ab labore sapiente voluptatem ratione illum voluptatem reprehenderit.
Corporis sint exercitationem doloremque impedit possimus
laboriosam^[STUFF THAT REFERS TO POSSIMUS LABORIOSAM] nesciunt. Ex enim
tenetur aut dolorem sequi et nihil.

Doing it manually is going to be somewhat tedious — not to the risk of
errors.

Seems a straightforward solution might consist in a regex-based search
of the files and populating some kind of associative array (dictionary?)
thusly as I go along:

  { '[1]' 'footnote #1', '[2]' 'footnote #2', ... }

... and proceed to a second pass that substitutes each anchor by the
contents of the corresponding footnote.

Before I do this, I was wondering if anyone had come across a similar
problem and might have come up with an elegant solution - i.e. one that
relies on a clever utilisation of vim's search & replace features rather
than writing code.

Thanks,

CJ

¹ upper case for highlighting/legibility purposes.
² ^[blah...] markdown syntax.

-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_use+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_use/20200621231816.GA25135%40turki.local.

Reply via email to