On 14 May 2021, at 13:04, Cooper Cavalier <[email protected]> wrote:
> The endnote looks like this:
> <h3 pb_toc=index><a href="#_ftnref18" name="_ftn18" 
> title="">[18]</h3><sup>[18]</sup></a>See Werner G. Marx, &quot;Money Matters 
> in Matthew,&quot; <i>Bibliotheca Sacra</i> 136:542 (April-June 1979):148-57.

That is going to be harder if your endnotes do not have closing tags. I am not 
sure that the jquery suggestion will work at all, and a script is going to have 
to know where the note ends, which will take some code depending on how the 
footnote is formatted.

If you can add end tags or the note is on a single logical line, it becomes a 
lot simpler. However, with no closing tags and the endnote one a single line by 
itself, something likes this: 

Script searches Fo;e1 for
<sup><a href="#_ftn19" name="_ftnref(\d+)">\[\d+\]</a></sup> 

And assigns \1 to something like $footNum then searches for

<h3 pb_toc=index><a href="#_ftnref\d+" name="_ftn${footNum}" 
title="">\[\d+\]</h3><sup>\[\d+\]</sup></a>(.*)

In the File2. In the second search, \1 is the contents of your footnote, say 
$footText

You will replace your first search found text in File1 with:

<pb_endnote>$footText</pb_endnote>

BUT, this assumes that all the footnotes are formatted exactly the same way.

Obviously, work on a duplicate copy of File1

You could do this all in awk, but only if you have already endured the pain of 
learning awk which I'm guessing you haven't because then you would have just 
used awk. Awks is very powerful, obtuse, and unforgiving.

I would probably end up writing this as a shell script with sed because awk 
makes my head hurt.

Basic login:

Repeat with each line {
If it contain a footnote {
get the number
Search File2 for the footnote text
Replace the <sup></sup> with the footnote text
}
}
Write the new file

Multiple footnotes together will be another step, or run the script multiple 
times until there are no matches.

-- 
DODGEBALL STOPS AT THE GYM DOOR Bart chalkboard Ep. BABF12

-- 
This is the BBEdit Talk public discussion group. If you have a feature request 
or need technical support, please email "[email protected]" rather than 
posting here. Follow @bbedit on Twitter: <https://twitter.com/bbedit>
--- 
You received this message because you are subscribed to the Google Groups 
"BBEdit Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bbedit/D607D152-7C12-429F-9A74-B64B982AC56E%40kreme.com.

Reply via email to