• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Selecting all text between paragraph styles

Explorer ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Hi,

For a bibliography I'm working on, I'd need to select all text between paragraph styles and have that text crossed-out or have the formatting changed so that it won't be picked up by an indexing program. 

For instance:

TITLE 1 (paragraph style 1 or 2) [paragraph break]

Text text text text text text (paragraph style 3)

TITLE 2 (paragraph style 1 or 2) [paragraph break]

Text text text text text text (paragraph style 3)

TITLE 3 (paragraph style 1 or 2) [paragraph break]

Text text text text text text (paragraph style 3)

 

This should become:

TITLE 1 (paragraph style 1 or 2) [paragraph break]

Text text text text text text (paragraph style 3)

TITLE 2 (paragraph style 1 or 2) [paragraph break] 

Text text text text text text (paragraph style 3)

TITLE 3 (paragraph style 1 or 2) [paragraph break]

Text text text text text text (paragraph style 3)

 

Text is always set in Paragraph Style 3, and the info before/after is always set in Paragraph style 1 or 2, followed by a paragraph break.

 

Thanks! 

 

 

 

TOPICS
Scripting

Views

333

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , May 03, 2024 May 03, 2024

Hi @eib24740488m4un I've written a script to do this based on your example. It probably will need some additional tweaking to suit your exact needs, but I suggest you try it out and let me know what it doesn't get right.

- Mark

demo.gif

/**
 * @file Paragraphs After Paragraphs.js
 * Applies `strikeThru` to 'BODY' paragraphs
 * occurring after 'HEADER' paragraphs and not
 * after 'TITLE' paragraphs.
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/selecting-all-text-betwe
...

Votes

Translate

Translate
Community Expert ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Text is always set in Paragraph Style 3

Use find change: leave the fields empty and use the magnifying glass icon to search text using paragraph style 3

Capture d’écran 2024-04-22 à 12.45.38.png

Or I don't understand the question…

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Sorry, you're right. I didn't say this is a very long document (1000 pages) with over 4000 entries. I need to have some of those paragraph style 3 sections crossed out, but not all of them. Also, using TITLE only was not appropriate as there are HEADERS, too. We're talking about section entries that always bear the same name and paragraph style.

For instance: 

TITLE 1 (paragraph style 1 ) [paragraph break]

Text text text text text text (paragraph style 3)

HEADER 1 (paragraph style 2 ) [paragraph break]

Text text text text text text (paragraph style 3)

HEADER 2 (paragraph style 2) [paragraph break]

Text text text text text text (paragraph style 3) [double paragraph break]

 

TITLE 2 (paragraph style 1 ) [paragraph break]

Text text text text text text (paragraph style 3)

HEADER 1 (paragraph style 2 ) [paragraph break]

Text text text text text text (paragraph style 3)

HEADER 2...

 

This should become:

 

TITLE 1 (paragraph style 1 ) [paragraph break]

Text text text text text text (paragraph style 3) -- needs indexing.

HEADER 1 (paragraph style 2 ) [paragraph break]

Text text text text text text (paragraph style 3) -- needs no indexing.

HEADER 2 (paragraph style 2) [paragraph break]

Text text text text text text (paragraph style 3)[double paragraph break] -- needs no indexing.

 

TITLE 2 (paragraph style 1 ) [paragraph break]

Text text text text text text (paragraph style 3) -- needs indexing.

HEADER 1 (paragraph style 2 ) [paragraph break]

Text text text text text text (paragraph style 3) -- needs no indexing.

HEADER 2...

 

So I'd need to be able to select the text (always PS3) bewteen headers (always PS2) or between headers and titles (always PS2 and PS1).

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 22, 2024 Apr 22, 2024

Copy link to clipboard

Copied

Thanks, I took a look at that, but using that GREP selects the first character of the PS3 only in my case, not the entire paragraph that needs to be crossed-out. Also, it selects all PS3 instances, not only those between PS2 or PS2 and PS1.

It probably needs some tweaking to work in my case, I just don't know how do it.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
May 03, 2024 May 03, 2024

Copy link to clipboard

Copied

Hi @eib24740488m4un I've written a script to do this based on your example. It probably will need some additional tweaking to suit your exact needs, but I suggest you try it out and let me know what it doesn't get right.

- Mark

demo.gif

/**
 * @file Paragraphs After Paragraphs.js
 * Applies `strikeThru` to 'BODY' paragraphs
 * occurring after 'HEADER' paragraphs and not
 * after 'TITLE' paragraphs.
 * @author m1b
 * @discussion https://community.adobe.com/t5/indesign-discussions/selecting-all-text-between-paragraph-styles/m-p/14570941
 */
function main() {

    var doc = app.activeDocument,
        text = doc.selection[0];

    if (
        undefined == text
        || !text.hasOwnProperty('paragraphs')
    )
        return alert('Please select some text and try again.');


    for (var i = 0, collecting = false, para; i < text.paragraphs.length; i++) {

        para = text.paragraphs[i];

        if (
            'HEADER 1' === para.appliedParagraphStyle.name
            || 'HEADER 2' === para.appliedParagraphStyle.name
        )
            // start collecting
            collecting = true;

        else if ('TITLE' === para.appliedParagraphStyle.name)
            // stop collecting
            collecting = false;

        else if (
            collecting
            && 'BODY' === para.appliedParagraphStyle.name
        )
            // strikeThrough
            para.strikeThru = true;

    }

};
app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, 'Set strikethrough');

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 03, 2024 May 03, 2024

Copy link to clipboard

Copied

LATEST

Mark,

wow, that works wonders! No tweaking needed. Thanks a lot!!!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines