6 Replies Latest reply on Dec 6, 2008 11:58 AM by Roy McCoy

    Footnote behaviour

    Roy McCoy Level 1
      james hendrickx wrote:

      there's no number in the actual footnote (so it's just "this is my footnote text" in stead of "1 this is my footnote text".

      Best of luck with that, sorry I can't help you with it. I also have a number-losing experience with scripted text, which seems to be less serious than yours - at least I hope it isn't serious, and I'm mentioning it here anyway. I get TeX-coded text like this:

      *****

      {\bf Shengjin} \hfill\strut\hfill  (Lezh\"e) 4 000
      \\
      \index{pentroarto}
      {\bf D} kaj {\bf FD} (pentroarto): Agim Peraj, instruisto de pentroarto, 72 Shengjin, 4500 Lezh\"e; \tel (028) 2 12300, @: agimperaj@yahoo.it.

      *****

      I convert this with AppleScript:

      set properties to { find grep preferences:{ find what:"\\\\index\\{(.+)\\}\\r"}, change grep preferences:{ change to:"<Idx:=<IdxEnType:IdxPgEn><IdxEnRngType:kCurrentPage><IdxEnDispStr:$1>>"}}
      change grep document 1

      to codes conforming to what I get when I export indexed text in ID tagged-text format:

      {\bf Shengjin} \hfill\strut\hfill  (Lezhë) 4 000}
      <Idx:=<IdxEnType:IdxPgEn><IdxEnRngType:kCurrentPage><IdxEnDispStr:pentroarto>>{\bf D} kaj {\bf FD} (pentroarto): Agim Peraj, instruisto de pentroarto, 72 Shengjin, 4500 Lezhë; \tel (028) 2 12300, @: agimperaj@yahoo.it.

      When I reimport the copied text combined with a standard tagged-text head back into InDesign, it indexes correctly... but I don't see the page number of the entry in the index palette as I do with index entries normally. Can anyone tell me why this is, and if there's perhaps something else to be afraid of other than the nonappearance of the page number in the palette? I've made a couple of test indexes and they've all seemed okay, so the procedure seems to be working generally.


      Thanks,

      Roy McCoy
      Rotterdam, NL

        • 1. Re: Footnote behaviour
          Peter Kahrel Adobe Community Professional & MVP
          Maybe it's simply a matter of updating the index in the palette. But wouldn't it be easier to script everything to InDesign directly, rather than taking the tagged-text route?

          Peter
          • 2. Re: Footnote behaviour
            Roy McCoy Level 1
            Peter Kahrel wrote:

            > Maybe it's simply a matter of updating the index in the palette.

            Yes! Thanks!

            > But wouldn't it be easier to script everything to InDesign directly,
            > rather than taking the tagged-text route?

            Scripting everything in InDesign is exactly what I wanted and planned
            to do, and I succeeded pretty well though it took me too long and
            without Shane Stanley's help it would have wound up being a fiasco.
            The reason I used tagged text was that this provided me with coding to
            which I could adapt the TeX coding in the database text I received.
            Importing tagged text still seems as good if not better than doing a
            bunch of grep replacing on formatting codes, but if you can tell me
            how to convert

            \index{pentroarto}

            directly into an InDesign index entry, I might wind up being quite
            happy to get rid of the tagged-text importing part of the procedure.
            This may be easy and even obvious, but I don't know how to do it.


            Thanks again,

            Roy McCoy
            Rotterdam, NL
            • 3. Re: Footnote behaviour
              Peter Kahrel Adobe Community Professional & MVP
              I don't know AppleScript, but in general you'd go about it like this:

              1. Use Indesign's GREP to collect all Latex-style index items: find \\index\{[^}]+\}
              2. For each item in the found collection
              - extract the name of the topic (e.g. extract "pentroarto" from \index{pentroarto}
              - insert a topic:
              new_topic = app.activeDocument.indexes[0].topics.add ("pentroarto")
              - and a page reference:
              new_topic.pageReferences.add ("pentroarto", PageReferenceType.currentPage)
              3. Remove all Latex-style index entries: GREP replace \\index\{[^}]+\} with an empty string.

              Along these lines. Now you need to translate these JavaScript lines to AppleScript.

              Peter
              • 4. Re: Footnote behaviour
                Roy McCoy Level 1
                Oh, so it is indeed doable, then. Not this year because the job's
                already done and I don't have the time now, but I'll probably find
                myself with the inclination to give it a try next time. How about
                shooting me the JavaScript, then, for

                \index{folkloro_albana}

                yielding the compound entry

                folkloro
                albana [n]

                in the index. Thanks!


                Roy McCoy
                Rotterdam, NL
                • 5. Re: Footnote behaviour
                  Peter Kahrel Adobe Community Professional & MVP
                  I use the script below to create an index out of text markers. The script assumes a slightly different format for the tags: where you have
                  >\index{folkloro_albana}

                  the scripts wants this format:
                  >folkloro#albana

                  but it is easy to change the script to accept Latex-style formats.

                  Peter

                  /*--------------------------------------------------------------

                  DESCRIPTION: Build index
                  Peter Kahrel -- www.kahrel.plus.com

                  Build an index from text markers.
                  Text markers must look like <ix>dog#collie#border collie</ix>
                  where # is a (sub)topic separator

                  --------------------------------------------------------------*/

                  rebuild_index (app.activeDocument);

                  function rebuild_index (doc)
                     {
                     var markers = pagerefs (doc);
                     if (markers.length > 0)
                        {
                        if (doc.indexes.length == 0)
                           doc.indexes.add ();
                        else
                           doc.indexes[0].topics.everyItem().remove();
                        var index = doc.indexes[0];
                        var mess = create_message (30, 'Building index...')
                        for (var i = 0; i < markers.length; i++)
                           {
                           mess.text = markers[i];
                           // create topic
                           var new_topic = create_topic (index, markers[i]);
                           // find all text markers in the text
                           text_top = find_grep (doc, markers[i]);
                           for (var j = text_top.length-1; j > -1; j--)
                              try
                                 {
                                 new_topic.pageReferences.add (
                                    text_top[j].insertionPoints[-1],
                                    PageReferenceType.currentPage);
                                 }
                              catch (_){}
                           delete_marker (doc, markers[i])
                           }
                        }
                     }

                  function pagerefs (doc)
                     {
                     app.findGrepPreferences = app.changeGrepPreferences = null;
                     app.findChangeGrepOptions.includeFootnotes = true;
                     var f = find_grep (doc, '<ix>.+?</ix>');
                     return plain_array (f);
                     }

                  function plain_array (array)
                     {
                     var temp = [];
                     var known = [];
                     for (var i = 0; i < array.length; i++)
                        if (!known[array[i].contents])
                           {
                           temp.push (array[i].contents);
                           known[array[i].contents] = true;
                           }
                     array = [];
                     known = [];
                     return temp
                     }

                  // Create topic and any subtopics
                  function create_topic (doc_index, str)
                     {
                     var array = str.replace (/<\/?ix>/g, '').split ('#');
                     var new_top = doc_index.topics.add (array[0]);
                     for (var k = 1; k < array.length; k++)
                        new_top = new_top.topics.add (array[k]);
                     return new_top
                     }

                  function find_grep (doc, f)
                     {
                     app.findGrepPreferences = app.changeGrepPreferences = null;
                     app.findGrepPreferences.findWhat = f;
                     return doc.findGrep ()
                     }

                  function delete_marker (doc, m)
                     {
                     app.findGrepPreferences.findWhat = m;
                     app.changeGrepPreferences.changeTo = '';
                     doc.changeGrep ()
                     }

                  function create_message (le, title)
                     {
                     dlg = new Window('palette', title);
                     dlg.alignChildren = ['left', 'top'];
                     var txt = dlg.add('statictext', undefined, '');
                     txt.characters = le;
                     dlg.show();
                     return txt
                     }
                  • 6. Re: Footnote behaviour
                    Roy McCoy Level 1
                    Thanks, Peter. I'll have this archived for if and when I get around to
                    trying to avoid importing tagged text. It will be a good JavaScript
                    learning exercise, if and when I get around to that to.

                    Roy McCoy
                    Rotterdam, NL