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

Assign a different Paragraph Style to text exceeding textframe

Community Beginner ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

I posted this question here: Poetry book text formatting

I'm currently working on a poetry book layout and I came up with this struggle:

I have some long lines that don't fit in a single line and (without changing paragraph) and I'd like to have all of those extra lines automatically being right justified.

I tried using nested line style, but I only manage to apply a different Character Style (not a paragraph one) on the second line.

Is there a way to achieve what I need without having to manually format every "exceeding line"?

To say it in other words I need to have all lines longer than the text box right justified.

I hope I was clear enough (if not sorry, english is not my mother tongue).

User DBLjan​ suggested me to try with a script: "Find out which paragraph exceeds the textframe. Scripters can tell you, if theres a value for this, or if you have to find out the hard way: Compare first characters baseline y with the last character baseline y. If they differs, your line exceeds the textframe – now the script could apply another paragraph style for the right alignment", but I'm totally noob in scripting and I have no idea where to start...

Can anybody help?

Edit: See picture for a reference

IMG_8608.JPG

TOPICS
Scripting

Views

454

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
Guru ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

You can't have part of a paragraph right aligned and part left even if there on separate lines so you have to either add a right tab or separate them into separate paragraphs.

The below add the tabs

HTH

Trevor

var sel, story, paragraphs, paragraph, characterStyle, n;

sel = app.selection[0];

if (!sel || !sel.properties.baseline) {

    alert('No text Selection!');

    exit();

}

// change LongLine to the name of the style you want

characterStyle = app.activeDocument.characterStyles.itemByName('LongLine');

characterStyle = characterStyle.isValid && characterStyle;

story = sel.parentStory;

paragraphs = story.paragraphs.everyItem().getElements();

n = paragraphs.length;

while(n--){

    paragraph = paragraphs;

    if (paragraph.lines.length > 1){

        paragraph.lines.itemByRange(1,-1).insertionPoints[0].contents = SpecialCharacters.RIGHT_INDENT_TAB;

        if (characterStyle) {

            paragraph.lines.itemByRange(1,-1).appliedCharacterStyle = characterStyle;

        }

    }

}

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
LEGEND ,
Apr 03, 2017 Apr 03, 2017

Copy link to clipboard

Copied

LATEST

Hi Trevor,

The op wants to "right-align" the 2nd part of the poetry double-line (the para has a left-alignment).

Surely a same applied para style through the doc and I suppose in all the doc (maybe several stories …)!

(^/) 

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