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

I want when the line breaks, the space at the end of the line is not underlined... Indesign CC

Community Beginner ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Schermafbeelding 2020-09-25 om 17.26.19.png

TOPICS
How to , Scripting , Type

Views

1.2K

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

Enthusiast , Sep 29, 2020 Sep 29, 2020

Try this, "char" is a reserved word you can't use as variable name

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Revert underlining");

function main () {
var story = app.selection[0].parentStory;
var lines = story.lines.everyItem().getElements();
for (var i = 0; i < lines.length; i++) {
    var c = lines[i].characters[-1];
    if (c.underline && c.contents == " ") {
      c.underline = false;
   }
}
}

Also, I added a undo 🙂

Votes

Translate

Translate
Community Expert ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

You may not like this answer, but if you don't want the underline to carry over into the space when underline an entire paragraph, you need to remove the current underlining and then redo it individually for each line of the paragraph.

 

Wish I had better news for you,

 

Randy

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 Beginner ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Dont you think there would be a script for that?
Thanks a lot for your reply! Eva

Sent from my Phone

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 ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

I frankly don't know.

 

But if you define the underline by a script, it's going to have to be pretty savvy to re-define the fix if there are any copyfit changes. At least if you do it by hand, it can be pretty easily fixed/changed by hand if it's needed.

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 Beginner ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

I understand!
But I have almost 200 pages like this ;—)



Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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 ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

Ow. My heart's with you, and my hand is instinctively cramping at the thought of it.

 

BrianP has provided a script below that'll hopefully work for you, but I'd wait to use it until the job is finally, entirely, set in stone.

 

Good luck,

 

Randy

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 ,
Sep 25, 2020 Sep 25, 2020

Copy link to clipboard

Copied

With your text cursor selected into the text: 

 

 

var story = app.selection[0].parentStory;
var lines = story.lines.everyItem().getElements();
var char;
for (var i = 0; i < lines.length; i++) {
    char = lines[i].characters[-1];
    if (char.underline && char.contents == " ") {
      char.underline = false;
   }
}

 

 

Of course, this is pretty risky if the text flow changes. 

 

If there was no hyphenation or other cause to ensure the last character in a line was a space, you could just make it a one-liner: 

app.selection[0].parentStory.lines.everyItem().characters.lastItem().underline = false;

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 Beginner ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

Hi Brian! Thanks! I actually don't really know how the handle or use this script - as I am not really used to do so... Could you tell me where to put or copy-paste it? Thanks! 

 

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 ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

https://indesignsecrets.com/how-to-install-a-script-in-indesign-that-you-found-in-a-forum-or-blog-po...

 

Click in your text with your text tool then run the script. It will work on all linked text frames for that story.

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 Beginner ,
Sep 26, 2020 Sep 26, 2020

Copy link to clipboard

Copied

thank you brian!!
It’s weird, i can’t select it :

(it says it can’t perform…)


[cid:A9CA7830-C701-4242-86D7-7899868CE526]

Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Sorry, I don't know what that error means. Ensure you saved the script as a plain text file with the .jsx extension, select inside a text frame with your cursor and try to execute the script. Was there other text besides that error line?

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 Beginner ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

I did the things like you proposed;
but the (!) says: "Dit bestand kan door geen van de ondersteunde scripttalen worden uitgevoerd"
if I translate it would be something like
"This file cannot be executed by any of the supported scripting languages”

Weird… hmmm… I ‘ll look further…
Anyway thanks a lot for your help!


Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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 ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

If using Text Edit in Mac, make sure you select the Make Plain Text option. 

 

Screen Shot 2020-09-27 at 8.53.51 AM.png

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 Beginner ,
Sep 27, 2020 Sep 27, 2020

Copy link to clipboard

Copied

Think that’s allright, too… ?

[cid:9F9BC5F5-7871-4458-AC35-3AD6A5BA50BB@lan]

Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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 ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Are you still getting the error "This file cannot be executed by any of the supported scripting languages”?

 

If so, there is an issue with how you are saving the script to your file. It should have a .jsx extension. Try uploading a screenshot of the file info for the script file. 

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 Beginner ,
Sep 29, 2020 Sep 29, 2020

Copy link to clipboard

Copied

Yes I do… ‘NEW.jsx’

The ‘underline_ski… file is visible though (but doesn’t work) …






[cid:aa82dfce-4392-45a5-adbd-d9e187c2d97b@eurprd04.prod.outlook.com]
[cid:0ef19b29-c4a1-4c0d-b0b0-e086e5fdd61d@eurprd04.prod.outlook.com]

Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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
Enthusiast ,
Sep 29, 2020 Sep 29, 2020

Copy link to clipboard

Copied

Try this, "char" is a reserved word you can't use as variable name

app.doScript(main, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "Revert underlining");

function main () {
var story = app.selection[0].parentStory;
var lines = story.lines.everyItem().getElements();
for (var i = 0; i < lines.length; i++) {
    var c = lines[i].characters[-1];
    if (c.underline && c.contents == " ") {
      c.underline = false;
   }
}
}

Also, I added a undo 🙂

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 Beginner ,
Sep 29, 2020 Sep 29, 2020

Copy link to clipboard

Copied

THIS WORKS!
THANKS A LOT JENS, YOU WON THE PRICE! :—)

MANY THANKS. I HOPE IT CAN HELP OTHERS TOO.
HAVE A NICE DAY!


Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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 Beginner ,
Mar 19, 2023 Mar 19, 2023

Copy link to clipboard

Copied

Hi there, I appreciate this post is over 2 years old but wondering if you can help here as the OP described exactly the same issue I'm having. The solution appears very elegant but my scripting knowledge is pretty minimal and when I try the above I am getting this error.

 

Any clues what I might be doing wrong?Screenshot 2023-03-19 at 23.05.51.png

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 Beginner ,
Mar 19, 2023 Mar 19, 2023

Copy link to clipboard

Copied

LATEST

Ignore previous post, I restarted Indesign and it works a peach - thank you so much for this script, it's amazing!

 

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
Enthusiast ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Not sure why you wanna use a script for that... a simple GREP within the paragraph style does it:

\s(?=\n|$)



GREP for Underline.jpg

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
Enthusiast ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Posted the wrong screenshot, here you actually see it working:
GREP for Underline.jpg

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 Beginner ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Hi Jens thanks!
How come your text is underlined while ‘underline’ is checked out… ?


Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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
Enthusiast ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

- The paragraph style has underline checked.
- The character style is set to not underline.
- Via GREP you apply the non-underline character style to every space at the end of the line.

But I just realized you have to set a manual line break in order for the GREP to work.
I don't know if there is a expression for automatic breaks...

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 Beginner ,
Sep 28, 2020 Sep 28, 2020

Copy link to clipboard

Copied

Ha! That is what I thought…
Well as it is about a lot of text (making a book with this style in it), it is (almost) impossible to give a manual line break each time…
Hmmm!!


Vriendelijke groeten,
Eva Goethals

T +32 485 31 37 91
https://www.evagraphics.com
https://www.linkedin.com/in/eva-goethals-61b5a3108/

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