22 Replies Latest reply on May 25, 2018 12:09 AM by amanm5143

    convert text to footnote

    gert verrept Level 2

      8.      de chercher plus de véritables [1] partenariats avec la société civile afin que les défenseurs des droits de l'homme se sentent pleinement [2] soutenus par l'UE;

       

      [1] HRW: Central Asia : Five Years of EU engagement

      [2] http://www.senat.fr/rap/r96-2013,1054/r96-374.html.

       

      This is a little sample of xml-text we get from external sources. There's no link between the false "footnote-ref [1]" in de text and the false "endnote text".

      Is there a possibility to convert those "notes" to real notes in de text, but not to end-notes? Sometimes these kind of notes extend to more than 100.

       

      thnkx

        • 1. Re: convert text to footnote
          Peter Kahrel Adobe Community Professional & MVP

          If you can identify uniquely the references in the text ([1], [2], etc) and the notes/note numbers, then yes.

          • 2. Re: convert text to footnote
            gert verrept Level 2

            Yes, the structure is always the same. We get [1] in the text and at the end of the complete story the [1] followed by the footnote text. All footnotes are numbered from [1] till ...

            • 3. Re: convert text to footnote
              Peter Kahrel Adobe Community Professional & MVP

              That was clear from your first post. My question was: is every number in brackets in the text a footnote reference?; and is every number in brackets at the start of a paragraph a footnote number?

              • 4. Re: convert text to footnote
                gert verrept Level 2

                Sorry, misunderstood your question, but indeed, every number between [ ] is a footnote reference and every [ ] at the start of a para is a footnote number.

                • 5. Re: convert text to footnote
                  Jump_Over Level 5

                  Hi,

                   

                  Just to show the way:

                  var 
                      myDoc = app.activeDocument,
                      mStory = myDoc.textFrames.item("story").parentStory,
                      mEndNotes = myDoc.textFrames.add( {name:"EndNotes"} ),
                      k, len, cIP, currPara, currFoot, mMarkers;
                  
                  app.findGrepPreferences = app.changeGrepPreferences = null;
                  //---------------------------------------------
                  // edit doc.footnoteOption here
                  with (myDoc.footnoteOptions) 
                      {
                      showPrefixSuffix = FootnotePrefixSuffix.PREFIX_SUFFIX_BOTH;
                      prefix = "[";
                      suffix = "]";
                      separatorText = "\t";
                      markerPositioning = FootnoteMarkerPositioning.NORMAL_MARKER;
                      }
                  //------------------------------------------------------------
                  // move endnotes to a separate textFrame
                  for (k=mStory.paragraphs.length - 1; k >=0; k--) 
                      {
                      if (mStory.paragraphs[k].contents.search(/^\[\d+\]/) == 0) 
                          {
                          currPara = mStory.paragraphs[k].move(LocationOptions.AT_BEGINNING, mEndNotes.parentStory);
                          currPara.words[0].remove();
                          }
                      }
                  //--------------------------------------
                  // create footnote markers
                  app.findGrepPreferences.findWhat = "\\[\\d+\\]";
                  mMarkers = mStory.findGrep();
                  len = mMarkers.length;
                  while (len-->0) {
                      cIP = mMarkers[len].insertionPoints[0].index;
                      mMarkers[len].remove();
                      mStory.footnotes.add( LocationOptions.AFTER, mStory.insertionPoints[cIP] );
                      }
                  //-------------------------------------------------------
                  // fill footnote contents with proper text
                  for (k=0; k < mStory.footnotes.length; k++) {
                      currFoot = mStory.footnotes[k];
                      mEndNotes.paragraphs[0].texts[0].move(LocationOptions.AT_END, currFoot.texts[0]);
                      if (mStory.footnotes[k].characters[-1].contents == "\r") mStory.footnotes[k].characters[-1].remove();
                      }
                  
                  mEndNotes.remove();
                  

                   

                  Assumings:

                  • both text and endnotes are in the same story
                  • one of this story's textContainer is named "story"
                  • each endnote is a separate (one) paragraph
                  • initially there is a white space after endnote's number

                   

                  Jarek

                  • 6. Re: convert text to footnote
                    gert verrept Level 2

                    Perfect. Just had to change "story" to our frame names, we use two frames, a Dutch and a French one (2 frames side by side), and run the script twice.

                    Thanks a lot Jarek.

                    • 7. Re: convert text to footnote
                      adriano.lucas

                      Hello Jarek,

                       

                      First of all, thank you for this script. It seems that it will do exactly what I am looking for. Also, kindly bear with me as I am a complete beginner with InDesign scripting.

                       

                      I'm trying to use your script for exactly the same reason as above, but I have an issue with one of the conditions given: "one of this story's textContainer is named 'story'" In the line:

                       

                          mStory = myDoc.textFrames.item("story").parentStory, 

                       

                      Is it possible to apply your script to the entire document (or story/stories)? Or, how do I attribute the name "story" to the current story in my document?

                       

                      Again, thank you for your help, Jarek.

                       

                      Adriano

                      • 8. Re: convert text to footnote
                        Jump_Over Level 5

                        adriano.lucas  napisał(-a)

                         

                        ...

                        Is it possible to apply your script to the entire document (or story/stories)? Or, how do I attribute the name "story" to the current story in my document?

                        ....

                        Hi Adriano,

                         

                        You need to assign a name "story" to one of textFrames which are your target story container (anyone).

                        I mean to assign this name using "Layer Panel" or adding a line of code.

                         

                        In case of target it to every stories - it should be rewritten...:)

                         

                        Jarek

                        • 9. Re: convert text to footnote
                          adriano.lucas Level 1

                          Great, thanks Jarek. I understand now. I've given the name "story" to a given layer, and it's working fine now :-).

                           

                          Adriano

                          • 10. Re: convert text to footnote
                            amanm5143 Level 1

                            Hey Jump_Over,

                            Firstly, thank you for such a great script. I have an assignment in line catering to a lot of footnotes in the same pattern and this could definitely save a lot of time for me. However, I am new to the scripting section and am not able to apply the script as it is giving me the same error of "story" as mentioned by Adriano Lucas.

                             

                            Could you guide me through the process of renaming the text frame to make the script work?

                             

                            I shall be highly obliged to you.

                            Regards,

                            Aman Mittal

                            • 11. Re: convert text to footnote
                              amanm5143 Level 1

                              Hey Adriano,

                              I have been facing the same problem. I have an assignment in line catering to a lot of footnotes in the same pattern and this could definitely save a lot of time for me.

                               

                              Could you guide me through the renaming process you applied so that I could make make the script work, too?

                               

                              I shall be highly obliged to you.

                              Regards,

                              Aman Mittal

                              • 12. Re: convert text to footnote
                                Jump_Over Level 5

                                Hi,

                                 

                                1. no need to modify script code

                                2. open target doc

                                3. find "Layer Panel" in app interface

                                4. select any textFrame which is a part of your target story

                                5. notice that "Layer Panel" made it selected as well --> double click there and change name to "story"

                                6. run script

                                 

                                Jarek

                                • 13. Re: convert text to footnote
                                  amanm5143 Level 1

                                  Hi,

                                  Thank you replying. I followed the steps however, the script gave me the same error. Kindly have a look at the image attached so confirm if I followed the right steps or not.

                                   

                                  Your help is greatly appreciated. Thanks a lot.Capture.PNG

                                  • 14. Re: convert text to footnote
                                    [Jongware] Most Valuable Participant

                                    Did you name a layer "story"?

                                    • 15. Re: convert text to footnote
                                      amanm5143 Level 1

                                      Yes! I tried to follow the steps, mentioned above. But, I think I got it all wrong. I have just started using InDesign and do not have much hold on it.

                                      • 16. Re: convert text to footnote
                                        Jump_Over Level 5

                                        Hi,

                                         

                                        assign name "story" to the textFrame not to the layer.

                                         

                                        Jarek

                                        • 17. Re: convert text to footnote
                                          amanm5143 Level 1

                                          Hi Jarek,

                                          I tried to name the text frame in Script Panel Palette and then ran the script. It gave me the same error. Could you instruct me on how to go about it?

                                           

                                          Thanks and Regards,

                                          Aman

                                          • 18. Re: convert text to footnote
                                            Jump_Over Level 5

                                            does this picture help you?screen.png

                                            • 19. Re: convert text to footnote
                                              Laubender Adobe Community Professional & MVP

                                              Hi Aman,

                                              you could handle this differently. Pehaps it's easier using a selection?

                                               

                                              Exchange this line of code:

                                              mStory = myDoc.textFrames.item("story").parentStory,
                                              

                                               

                                              with:

                                              mStory = app.selection[0].texts[0].parentStory,
                                              

                                               

                                              Before running the script select the text frame of your story. Or select some text of the story.

                                               

                                              Regards,
                                              Uwe

                                              • 20. Re: convert text to footnote
                                                amanm5143 Level 1

                                                Hi Uwe, Thank you replying to the post. I tried you way out and it worked, wonders. Thanks a lot! I am grateful to you. Regards, Aman

                                                • 21. Re: convert text to footnote
                                                  amanm5143 Level 1

                                                  Hi Jarek, Though the picture could have been of great help but I did not have any other frame other than 'Layer 1' in the Layer Panel so it brought me back to square one. However, I got th thing resoled through other means. So, thank you for helping out. Regards, Aman

                                                  • 22. Re: convert text to footnote
                                                    amanm5143 Level 1

                                                    Hey Jarek,

                                                    It's Aman, this side. I apologize for troubling you again but would be grateful if you could help me regarding the script on the below mentioned aspect.

                                                    I have a project in line having " * " as the marker for the footnotes as well as the footnote reference starts with " * " as well. How do we adjust the above script to convert the text to footnotes with * reference and marking?

                                                     

                                                    Also, is it possible to make the script pick up more than one paragraph for the conversion?

                                                     

                                                    Request you to assist me, in case you have a bit of time to spare.

                                                    Regards,

                                                    Aman Mittal  

                                                    Footnote.png