Article View: adobe.scripting.indesign
Article #8634Re: Get (relative) index of a paragraph inside a selection of paragraphs
From: Martin Fischer*
Date: Mon, 02 Oct 2006 08:19
Date: Mon, 02 Oct 2006 08:19
53 lines
2032 bytes
2032 bytes
Peter,
thanks for your advice too.
That's right.
This is my code with Dave's approach and a portion of Peter's input:
// cleanUpBib.jsx
var mySubst = "�,\t";
app.findPreferences = app.changePreferences = null;
cleanUpBib (app.selection[0]);
function cleanUpBib(textRef) {
var myParas = textRef.paragraphs;
var curName = "";
for (var j = myParas.length -1; j >= 0; j--) {
var bibName = getBibName(myParas[j]);
if (bibName) {
if ((bibName != curName) || (bibName == "")) {
curName = bibName;
} else {
clearBibName(myParas[j+1]);
}
}
}
}
function getBibName(thePara) {
if (theCommas = getCommas(thePara))
return thePara.parentStory.characters.itemByRange(thePara.characters[0], theCommas[1]).contents.join();
}
function clearBibName(thePara) {
if (theCommas = getCommas(thePara))
thePara.parentStory.characters.itemByRange(thePara.characters[0], theCommas[1]).contents = mySubst;
}
function getCommas(thePara) {
var theCommas = thePara.search( ', ' );
if (theCommas.length > 0)
return theCommas;
}
I didn't get success with my double loop approach yet.
And for the elaboration of Dave's approach works very well I will not spent more time to overwork my old moldered code. ;-)
Martin
Technical Details
Message-ID:
<3bc1d60c.10@webcrossing.la2eafNXanI>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!news.isoc.lu!webcrossingReferences:
<3bc1d60c.-1@webcrossing.la2eafNXanI>Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,11f901afe18132ac X-Google-Attributes: gidf939a,public X-Google-Language: ENGLISH,ASCII From: "Martin Fischer*" <martin.fischer@online.de> Path: arc1-ca.pugleaf.net!g2news2.google.com!news4.google.com!news3.google.com!news.glorb.com!news.isoc.lu!webcrossing Newsgroups: adobe.scripting.indesign Subject: Re: Get (relative) index of a paragraph inside a selection of paragraphs Message-ID: <3bc1d60c.10@webcrossing.la2eafNXanI> Date: Mon, 2 Oct 2006 01:19:44 -0700 References: <3bc1d60c.-1@webcrossing.la2eafNXanI> Lines: 53 MIME-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 8bit