Convert faux footnote numbers (superscripted) to actual footnotes

Learn / Forums / InDesign Add-ons (Scripts, Scripting, and Plug-ins) / Convert faux footnote numbers (superscripted) to actual footnotes

Viewing 3 reply threads
  • Author
    Posts
    • #103850

      Hello everyone!

      I’ve been trying to patch together different scripts and queries that I found all over the internet to solve this problem, but it seems that GREP is beyond me for now.

      The problem I have is rather simple: There’s a book that has lots of ‘fake’ superscript numbers that were used as ‘endnote’ markers (fake endnotes, that is) and now I need to convert everything to proper footnotes.

      I’m looking for a way to automatize this process, and replace all those superscript numbers with footnote insertions, where I can afterwards just go in an place the proper text. I ask this because the book is huge, since I would’ve done it manually if it were a few endnotes to deal with…

      To summarize, need script that will convert superscripted text to proper footnote insertion.

      I have no idea how to make a script that could automatically do this. If anyone can lend a hand, I will be eternally grateful.

      Thank you so much,
      Alex

    • #103851

      To give a jumpstart to the conversation, I’ve found a script very similar to the one I’m looking to achieve, created by Peter Kahrel in [url=https://creativepro.com/topic/use-grep-to-put-in-footnote-reference]this[/url] post a while back:

      [code]
      (function () {
      var i;
      var placeholders;
      var fnote;
      app.findGrepPreferences = null;
      app.findGrepPreferences.findWhat = '\\[\\[(.+?)\\]\\]';
      placeholders = app.documents[0].findGrep();
      for (i = placeholders.length-1; i >= 0; i--) {
      fnote = placeholders[i].insertionPoints[0].footnotes.add();
      placeholders[i].move (LocationOptions.AFTER, fnote.insertionPoints[-1]);
      }
      }());
      [/code]

      P.S. I have no idea what the formatting code is for this forum.

    • #103856

      I think I’ve nailed the script and from primary tests it works fine. Here’s the code:

      app.findGrepPreferences = null;
      app.findGrepPreferences.findWhat = ‘\\d+’;
      app.findGrepPreferences.position = Position.SUPERSCRIPT;
      found = app.activeDocument.findGrep();
      for (i = found.length-1; i >= 0; i–) {
      found[i].insertionPoints[0].footnotes.add();
      found[i].remove();
      }

    • #103886

      ??? …

      • #103887

        I can’t really reply to a set of three question marks. Care to be more explicit?

Viewing 3 reply threads
  • You must be logged in to reply to this topic.
>