On 14 May 2021, at 12:04, Cooper Cavalier wrote:
> I have a text/html file which has thousands of endnotes. The file has
> the
> inline endnote reference as [1], [2], [3], etc. which correspond to
> the
> appropriate endnote. For the app publisher I am working for, the
> endnotes
> must be placed in line with specific coding.
>
> I am totally stumped in finding a way either inside of Bbedit or using
> a
> Python script. I am doing this editing on a Mac.
Looks like a script would make a pass through the doc to find all the
inline links and match them to their endnotes (confirming, too, that the
end note exists and that every link has an endnote).
Perhaps the result of that first pass would be a lookup hash of the
relevant info for each citation instance, with the ref numbers as the
hash’s keys.
Then a second pass: regex matching on the overall pattern of the
citation link with a () capture of the ref number. The ref number is
then looked up in the hash, and the citation info stored there is
substituted for the original citation link verbiage.
I can’t guide you for doing this in Python, but I assume it has regex
etc capabilities to do the above; Perl, my preferred programming
language, wrote the book.
If the above possible approach still requires you to devote more time
than you have to expanding your scripting-fu, there are several
scripting adepts on this list who might offer scripts in Perl,
Applescript, Javascript, Python, and of course multi-step find/replace,
text factories, etc in BBEdit.
HTH
> *Currently the inline link looks like this:*
> <p>It has been estimated that about one-fifth of Jesus' teachings was
> about
> money matters.<sup><a href="#_ftn19" name="_ftnref19">[19]</a></sup>
>
> *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, "Money
> Matters in Matthew," <i>Bibliotheca Sacra</i> 136:542 (April-June
> 1979):148-57.
>
> *It needs to instead look like this:*
> <p>It has been estimated that about one-fifth of Jesus' teachings was
> about
> money matters.<pb_endnote>See Werner G. Marx, "Money Matters in
> Matthew," <i>Bibliotheca Sacra</i> 136:542 (April-June
> 1979):148-57.</pb_endnote>
>
> Any help would be deeply appreciated since there is no way I can do
> this
> manually.
>
> Thank you!
>
> Doug
>
>
Thanks,
- Bruce
_bruce__van_allen__santa_cruz__ca