Copy link to clipboard
Copied
I've seen a posts here about using the "Convert Bullets to Text" contextual option in text as well the method app.activeDocument.stories.everyItem().convertBulletsAndNumberingToText(); however neither is satifactory so ive been writing a script to change the copy in a document that has a bullet or number list style applied to converted text, but i'm having trouble figuring out how to script going through the text, identifying the ones with specific paragraph styles ( there are 6 styles, all set within two layers of groupings: Body Styles [group] > Lists [group] > Bullet lvl 1 [style].
heres what ive tried to so, but i realized that it was converting the whole style not the text with the style.
Rather than using InDesign's Find to look for styles, you may be better off cycling through paragraphs and checking their style names. Something like this:
par = doc.stories.everyItem().paragraphs.everyItem().getElements();
re = /(Bullet|Num) lvl [123]/;
for (i = 0; i < par.length; i++) {
if (re.test (par[i].appliedParagraphStyle.name)) {
// do something
}
}
Peter
Copy link to clipboard
Copied
all those bottom lines are shown as commented out, i just forgot to un-comment them before posting but when active they convert the entire style to text, removing the list formatting entirely, and
Copy link to clipboard
Copied
You can go back and re-edit your original post - there is no time limit.
Copy link to clipboard
Copied
I dont see any option to edit a post or comment, am i just completely missing it?
Copy link to clipboard
Copied
Click '. . . More' and one of the options is 'Edit message'.
Copy link to clipboard
Copied
I don't see that option on any of posts or comments. under my post i have: views, translate, report, follow, and reply. would be labeled as community beginner effect the options on posts i have?
Copy link to clipboard
Copied
I've no idea.
Copy link to clipboard
Copied
Hi @SweatersInSummer , I think you need to loop through the paragraphs and remove the overrides that are created when you change the paragraph stylesāparagraph.clearOverrides()
https://www.indesignjs.de/extendscriptAPI/indesign-latest/#Paragraph.html#d1e501544__d1e508156
Copy link to clipboard
Copied
Rather than using InDesign's Find to look for styles, you may be better off cycling through paragraphs and checking their style names. Something like this:
par = doc.stories.everyItem().paragraphs.everyItem().getElements();
re = /(Bullet|Num) lvl [123]/;
for (i = 0; i < par.length; i++) {
if (re.test (par[i].appliedParagraphStyle.name)) {
// do something
}
}
Peter
Copy link to clipboard
Copied
This was the answer i was circling around, thank you Peter. I was trying to loop through the paragraphs but had difficulty figuring out the correct syntax to access the .paragraphs, but the InDesign Object Model on indesignjs.de is kind of difficult to understand at times. for posterity my final code looks like:
var doc = app.activeDocument;
par = doc.stories.everyItem().paragraphs.everyItem().getElements();
re = /(Bullet|Num List) lvl [123]/;
for (i = 0; i < par.length; i++) {
if (re.test (par[i].appliedParagraphStyle.name)) {
par[i].convertBulletsAndNumberingToText();
}
}
alert('Bullet lvl 1, 2, 3 and Number List lvl 1, 2, 3 converted to text.')