kline has asked for the wisdom of the Perl Monks concerning the following question:

Fellow hackers,

I am/have been/will be scanning and OCR'ing some favorite and pubdom texts. Editing out the dross is a by-hand task, but over the years I've developed C programs to handle a lot of the HTML stuff. perl s/foo/bar/g substitution has been a win, but for handling the footnotes, toc,and index, I need serious help!

On my by-hand 2nd Pass, I've been putting footnte subscripts in brackets; e.g., for the 9th superscript, I have [9]. Can any of you wizards suggest a perl program that takes [NN] and subs:
"<SUB><A HREF="NN"><B>FONT SIZE="-3"><B> NN &nbsp;</FONT></B></SUB>
?

Because the NN stuff is at the bottom of each page, this is likely another by-hand task. But having a perl script handle the superscripts would be a ++plus.

merci d'advanc!

gary

Replies are listed 'Best First'.
Re: automating superscripting in HTML
by jonadab (Parson) on Mar 22, 2006 at 01:48 UTC
    Can any of you wizards suggest a perl program that takes [NN] and subs: "<SUB><A HREF="NN"><B>FONT  SIZE="-3"><B> NN &nbsp;</FONT></B></SUB>

    Is this a trick question? What's wrong with the obvious solution?

    s![[](\d+)[]]!<sup class="footnotemark"><a href="#$1"><strong>$1</strong></sup>!g;

    What have you tried? What is wrong with the results?


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. Why, I've got so much sanity it's driving me crazy.
      Not a trick question; and the solution that's obvious to you, wasn't so obvious to me. The regex you've got with the backets was a stumbling point.... maybe the only one.

      Besides the on-page footnote pointers, there are at least 8 pages of index listing that have to point to the appropriate page. I may be able to use your solution there too, thanks.
Re: automating superscripting in HTML
by zer (Deacon) on Mar 22, 2006 at 02:00 UTC
    Take a look at How do I post a question effectively
    I am probably not the only person who has no idea what you are asking.
    Id like to help you, why dont you show us some code you are using and better explain your situation and the task you need to get done?