> On May 14, 2021, at 1:08 PM, @lbutlr <[email protected]> wrote:
>
> 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.
Point well-taken: If the HTML malformed jQuery won't work until it's fixed, but
I suspect it's just a cut & paste error in the OP?
If not, some JS automation can probably fix it, and barring that, some manual
fixes.
The JS/JQ code would be something like this (forgive any typos -- couldn't
test, and is based on your example.)
$("a").each(inlineA => {
if (inlineA.href.indexOf("#_ftn") < 0) return; //skip all anchors that
don't refer to endnotes.
var inlineSup = inlineA.parentNode; //Gets the <sup> element that
contains inlineA
var endNoteName = inlineA.href.substr(1); //get the endnote anchor name
from the inline anchor's href
var endNoteA = $(`a[name="${endNoteName}"]`);
if (endNoteA.length == 0) {
console.log("Failed to find this endnote " + endNoteName);
return;
}
if (endNoteA.length > 1) console.log("Note: There's more than one
endnote!");
endNoteA = endNoteA[0]; //get only the first endnote for this inline
anchor.
endNoteH3 = endNoteA.parentNode; //get the h3 element containing the
endnote anchor.
pbEndnote = $("<pb_endnote>").html(endNoteH3.innerHTML)[0]; //Make the
<pb_endnote> and fill it. Needs a little cleanup.
$(pbEndNote).find("a").remove(); //This is the cleanup.
$(inlineSup).replaceWith(pbEndNote); //puts the <pb_endnote> into place.
});
> On May 14, 2021, at 1:08 PM, @lbutlr <[email protected]> wrote:
>
> On 14 May 2021, at 13:04, Cooper Cavalier <[email protected]
> <mailto:[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, "Money Matters
>> in Matthew," <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 <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]
> <mailto:[email protected]>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/bbedit/D607D152-7C12-429F-9A74-B64B982AC56E%40kreme.com
>
> <https://groups.google.com/d/msgid/bbedit/D607D152-7C12-429F-9A74-B64B982AC56E%40kreme.com?utm_medium=email&utm_source=footer>.
--
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/EBC21DB0-EB20-4909-86D6-6DB502B75851%40gmail.com.