Copy link to clipboard
Copied
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
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 = "]";
separator
Copy link to clipboard
Copied
If you can identify uniquely the references in the text ([1], [2], etc) and the notes/note numbers, then yes.
Copy link to clipboard
Copied
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 ...
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
.contents.search(/^\[\d+\]/) == 0) {
currPara = mStory.paragraphs
.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
; mEndNotes.paragraphs[0].texts[0].move(LocationOptions.AT_END, currFoot.texts[0]);
if (mStory.footnotes
.characters[-1].contents == "\r") mStory.footnotes .characters[-1].remove(); }
mEndNotes.remove();
Assumings:
Jarek
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Great, thanks Jarek. I understand now. I've given the name "story" to a given layer, and it's working fine now :-).
—
Adriano
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Did you name a layer "story"?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Hi,
assign name "story" to the textFrame not to the layer.
Jarek
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
does this picture help you?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
I'd like to use this code but is there a way to automatically add a number at the beginning of the text which will become the footnote and a number at the end of the paragraph?
Or is there a way this can be done without numbers?
Copy link to clipboard
Copied
Hi @Summayah5FC7 ,
how would you know where the reference should be positioned in the main text?
And how you would you know where the footnote text is?
I cannot see this from your screenshot.
Regards,
Uwe Laubender
( Adobe Community Professional )