Skip to main content
gert verrept
Inspiring
January 27, 2014
Answered

convert text to footnote

  • January 27, 2014
  • 2 replies
  • 5780 views

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

This topic has been closed for replies.
Correct answer Jump_Over

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.


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:

  • 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

2 replies

Inspiring
July 1, 2022

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?

Community Expert
July 1, 2022

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 )

Inspiring
July 1, 2022

The document is just stories extracted from different books.

Each story starts with a Drop cap. The first paragraph of each story has been assigned a 'Body 1' character style.

The remaining

The footnote text appears after the story and has been assigned a paragraph style.

Peter Kahrel
Community Expert
Community Expert
January 27, 2014

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

gert verrept
Inspiring
January 27, 2014

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 ...

Peter Kahrel
Community Expert
Community Expert
January 27, 2014

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?