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

Highlighting non-contiguous words/phrases so a paragraph style can be assigned in one click

Explorer ,
May 22, 2025 May 22, 2025

I read an old question (2019) that said you cannot highlight non-contiguous words/phrases. I'm wondering if this has changed now and if there is a way to do this. I want to highlight subheadingins in chapter and assign a paragraph style and change them with one click!

 

TOPICS
How to
265
Translate
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 22, 2025 May 22, 2025

Nothing's changed. Could likely be scripted.

If you're bringing styled text in, you could map styles from Word or do a find/change, but that requires some forethought.

Translate
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 22, 2025 May 22, 2025

It's been a bit of a nightmare. The Word document had been copied from a PDF (far from ideal) then amended so of course the formatting was all over the place. So I had to import into Indesgn and then assign character styles to the text (as there were italics and bold interspersed amongst the text that I wanted to keep and two styles of typeface) so I could then unformat the text but keep the italics and bold in place. I have then had to create paragraph rules to use as well and remember to change character styles to 'none' so the paragraph style would work. As it is a laborious job that is now having to be formatted by hand, being able to highlight non-contiguous text would have saved me so much time.  

Translate
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 22, 2025 May 22, 2025

Again, could be scripted. In fact, my guess is that even ChatGPT or any other AI could write it for you. Here's a quick one from Co-Pilot. I strongly suggest saving the document first and running it on a copy.

 

I'd be curious to know how you make out with it.

 

// InDesign Script: Convert Manual Overrides to Styles
if (app.documents.length > 0) {
    var doc = app.activeDocument;

    // Function to apply character styles
    function applyCharacterStyles() {
        var allTextFrames = doc.textFrames;
        for (var i = 0; i < allTextFrames.length; i++) {
            var textFrame = allTextFrames[i];
            var text = textFrame.texts[0];

            // Loop through each character
            for (var j = 0; j < text.characters.length; j++) {
                var char = text.characters[j];
                if (char.appliedCharacterStyle == doc.characterStyles[0]) { // Default style
                    var newStyle = findOrCreateCharacterStyle(char);
                    char.appliedCharacterStyle = newStyle;
                }
            }
        }
    }

    // Function to apply paragraph styles
    function applyParagraphStyles() {
        var allParagraphs = doc.stories.everyItem().paragraphs.everyItem().getElements();
        for (var i = 0; i < allParagraphs.length; i++) {
            var para = allParagraphs[i];
            if (para.appliedParagraphStyle == doc.paragraphStyles[0]) { // Default style
                var newStyle = findOrCreateParagraphStyle(para);
                para.appliedParagraphStyle = newStyle;
            }
        }
    }

    // Helper: Create or find a character style based on formatting
    function findOrCreateCharacterStyle(char) {
        var styleName = "CharStyle_" + char.fontStyle + "_" + char.pointSize;
        var existingStyle = doc.characterStyles.itemByName(styleName);
        if (!existingStyle.isValid) {
            var newStyle = doc.characterStyles.add({ name: styleName });
            newStyle.fontStyle = char.fontStyle;
            newStyle.pointSize = char.pointSize;
            return newStyle;
        }
        return existingStyle;
    }

    // Helper: Create or find a paragraph style based on formatting
    function findOrCreateParagraphStyle(para) {
        var styleName = "ParaStyle_" + para.justification + "_" + para.pointSize;
        var existingStyle = doc.paragraphStyles.itemByName(styleName);
        if (!existingStyle.isValid) {
            var newStyle = doc.paragraphStyles.add({ name: styleName });
            newStyle.justification = para.justification;
            newStyle.pointSize = para.pointSize;
            return newStyle;
        }
        return existingStyle;
    }

    // Run the functions
    applyCharacterStyles();
    applyParagraphStyles();

    alert("Manual overrides have been converted to styles!");
} else {
    alert("No document is open. Please open a document and try again.");
}

 

Translate
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 22, 2025 May 22, 2025

Can you clarify exactly what that script will do please. many thanks

Translate
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 22, 2025 May 22, 2025
It should take manually styled text and change it to a proper style. I'm not a scripter so I can't personally go through it and figure out each step. Someone else might chime in
Translate
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
LEGEND ,
May 22, 2025 May 22, 2025

@Wilton PublishingServices 

 

If you have access to WORD - you can use those macros in WORD first:

 

http://id-tasker.com/uploads/WordStyle.zip

 

They'll change all bold, italic, sub/super-scripts, underline - and all combinations - into CharStyles.

 

Then you can import this new text into InDesign.

 

Translate
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 22, 2025 May 22, 2025

Actually I changed the text into character styles after I imported the Word document so I could delete the formatting which worked fine. I then left justified the book and created paragraph styles for lists and any text without italics in it. Anything with italics in the paragraph I'm making any amendments needed manually although so far seems fine. What would save so much time is being able to highlight all the headings together and change and all the subheadings and change at once. But if only 18 poeple have asked for this then I guess Adobe think it's not needed that much, but I'm pretty sure more than 18 designer who are on here would find it useful!

Translate
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
LEGEND ,
May 22, 2025 May 22, 2025
LATEST
quote

[...] What would save so much time is being able to highlight all the headings together and change and all the subheadings and change at once. [...] 


By @Wilton PublishingServices

 

If you know "formatting" for the particular blocks of text - you can use Find&Change. 

 

Or if you work on Windows - even the free version of my tool could help you a lot - it can load all texts with different formatting - then you can filter by properties you're interested in - and re-style. 

 

It will take a few clicks - in comparison to the paid version - but will be much more convenient anyway. 

 

You will see contents of all pieces of text and quickly decide which one to style - no need to scroll through 100s of pages to find a few on each page. 

 

Translate
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 22, 2025 May 22, 2025

With so many asking for this I wonder why it hasn't been forthcoming! People have been asking for this for years.

Translate
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 22, 2025 May 22, 2025
Translate
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 22, 2025 May 22, 2025
Not to throw cold water on it, but 18 votes in five years? Not gonna get much traction.
Translate
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