Removing End of Line Underlines
Learn / Forums / General InDesign Topics / Removing End of Line Underlines
- This topic has 11 replies, 5 voices, and was last updated 4 years, 11 months ago by Kate Francis.
-
AuthorPosts
-
-
December 16, 2009 at 4:36 pm #54270emilydorrMember
Is there a way to remove the underlined space, that falls at the end of a line of text, that has underlines applied to multiple lines of text?
-
December 16, 2009 at 8:53 pm #54277Theunis De JongMember
Yes, that's annoying. ID cannot find/change something based on soft line endings, so a Javascript would come in handy. (Audience: “Javascript?”) Sure, no problem. Copy and paste the following one into a plain text editor (Notepad, TextEdit in plain text mode; best is Adobe's own ESTK editor that comes installed with InDesign) and save into your User Scripts folder as “NoUnderline.jsx”. Select an appropriate amount of text, and run the script. It will add a character style to underlined spaces at the end of each line, and leave other end characters (such as soft hyphens) alone. If your text changes and you want the underlines back, do the following:
1. Edit the character style “NoUnderline”; set Underlining on.
2. Delete the character style; select “Preserve Formatting”.
3. Run the script again on your selection of text.
Alternatively, select a run of text and remove the character style by replacing it with “[None]” and restore Underline in the Change Formatting box.
Here's the script:
//DESCRIPTION: Begone, Ugly End Of Line Underlining!
// (c) Jongware 16-Dec-2009
try {
blankStyle = app.activeDocument.characterStyles.item("NoUnderline");
} catch (_)
{
blankStyle = app.activeDocument.characterStyles.add();
blankStyle.name = "NoUnderline";
blankStyle.underline = false;
}
for (a=0; a<app.selection[0].lines.length; a++)
{
if (app.selection[0].lines[a].characters.item(-1).contents == " ")
app.selection[0].lines[a].characters.item(-1).appliedCharacterStyle = blankStyle;
}
-
December 17, 2009 at 3:40 pm #54290emilydorrMember
Thank you for helping me. I receive an error when I try to run the script.I am not very familiar with running scripts but have followed your directions to the “T” Again thanks for the help. Maybe I am doing something wrong?
Error Number 30477
Error String: Invalid value for set property
'appliedCharacterStyle.' Expected CharacterStyoe or
String, but received nothing.
Then it refers to where I have the script save followed by
Line:31
Source app.selection.[0].lines[a].character.items(-1).appliedC
haracterStyle = blankStyle;
-
December 17, 2009 at 8:36 pm #54291Theunis De JongMember
That's odd. The script is written & tested for CS4, but it ought to work for CS3 as well. (You are not using an even older version, are you?)
Can you check if it actually creates a character style called “NoUnderline”? If there isn't one, it should make it automatically. (FYI, the variable 'blankStyle' should point to this character style, and should apply it in lline 31.)
It seems you didn't do anything wrong copying or running the script, as it would never have made it all the way to that line.
-
December 17, 2009 at 8:50 pm #54292emilydorrMember
I am in CS4. And it didn't make a “NoUnderline” character style.Hummm
The whole document is layed out with Character Styles because the person who typeset in Microsoft Word used all “Normal” text. Does that make since? But had about 7 different formattings applied throughout the whole document. Guess they don't know how to use styles in Word.
I imported the text into InDesign, then did a change font for the fonts I used in my Characters Styles. Then went in and did a “Find/Change” to apply my Character Styles to the whole document. Normally I would use Paragraph Styles and then apply individual Character Styles but because of the Word document formatting the only thing that worked was all Character Styles.
Sorry for the long explanation but I thought it might help troubleshoot the javascript issue.
-
December 17, 2009 at 9:17 pm #54294Theunis De JongMember
Choke my throat and call me a smurf. I tested the script, and I am so positive it worked yesterday! But something goes wrong right at the very start — I stated that 'it should create the style automatically if it doesn't exist yet', and, for sure, that's the part where it fails!
Here is a new, improved version. Better, stronger, faster … well, it works. (I double-checked this time )
If you have a dedicated “Underline” character style as well, it makes removing this a bit easier. Just delete the style “NoUnderline” and replace with “Underline”. Then re-run the script, and it will re-create the style. (Honestly.)
//DESCRIPTION: Begone, Ugly End Of Line Underlining!
// (c) Jongware 16-Dec-2009
var blankStyle = app.activeDocument.characterStyles.item(“NoUnderline”);
try { blankStyle.index; } catch(_)
{
blankStyle = undefined;
}
if (blankStyle == undefined)
{
blankStyle = app.activeDocument.characterStyles.add();
blankStyle.name = “NoUnderline”;
blankStyle.underline = false;
}
for (a=0; a<app.selection[0].lines.length; a++)
{
if (app.selection[0].lines[a].characters.item(-1).contents == ” “)
app.selection[0].lines[a].characters.item(-1).appliedCharacterStyle = blankStyle;
}
-
December 18, 2009 at 6:02 pm #54304emilydorrMember
Still doesn't seem to work for me.
JavaScript Error!
Error Number: 8
Error String: Syntax Error
Then it names where it is save on my computer followed by
Line: 5
var blankStyle = app.activeDocument.characterStyles.item(”NoUnderline”)Offending Text: “
As I am not a script user I don't know how to trouble shoot. I really appreciate all your efforts.
-
December 18, 2009 at 9:30 pm #54306Theunis De JongMember
Ouch! Fortunately, you copied the error message exactly, so I can tell you right away what's wrong. (I hope.)
Since this forum is brand new, there isn't as yet an option to format code. I gave it a manual try in my first post, underhandedly editing the raw HTML for the message, so the script would show up as plain code. And one of the things that happen automatically is that double quotes do not get translated into the curly ones that show up in text! (Let me show. I type “Hey, Emily, cheer up! Almost there!” with straight quotes in the message editor. You'll see them as curly ones on your screen.)
As it was a sort of hacking David's otherwise very pretty new forum, and it also was a bit of trouble (and not really worth that either), I plainly copied the new script out of my editor into the message editor. And, well, there's when it went wrong. Both single quotes (which I didn't use) and double quotes in a script need to be of the straight up kind. If you use Adobe's own ESTK to edit the script, you'll see it recognizes the text strings and will change its colour when changed to the correct quotes.
Let's say I'm fairly confident it ought to work now.
-
December 21, 2009 at 6:47 pm #54310emilydorrMember
Oh my. This is like an early Christmas present! It worked. I don't know how to thank you enough. Hope it didn't take up too much of your time. I think I will tell my client they get to see the pesky underlines until the last proof and then I'll run the script on however many pages the book turns into, right now it is looking like she is writing a 800+ page book and she likes her underlines!
Thanks again.
-
December 22, 2009 at 6:55 pm #54319David BlatnerKeymaster
That is awesome, Theun! I have posted the script here (with straight quotes), in case anyone else wants to grab it more easily.
https://creativepro.com…..rlines.jsx
(right click on the link to download it to disk, and save it in your scripts folder, as mentioned here)
-
March 30, 2010 at 12:47 pm #55370AnkeGParticipant
Oh my, I have been searching for a solution for this for 2 hours and finally came to this post.
Thank you soooo much, the second script worked for me, OS 10.6.2, InDesign CS3 :-)
-
April 17, 2019 at 7:19 pm #116161Kate FrancisMember
I’m a little late to this party but this is exactly the sort of script I was looking for (I think!), but I can’t seem to get it to work!
It creates the NoUnderline character style, but then, does nothing else.I am not good with scripts so I’m not sure what I’m doing wrong. I’m not getting an error.
My underlines are a paragraph style.
I can manually apply the new NoUnderline style which works, but obviously I could have done that without the script.Just to confirm, what I’m wanting is to remove underlines on trailing white space at the end of a line (not a paragraph)..
-
-
AuthorPosts
- You must be logged in to reply to this topic.