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

remove end of paragraph symbol in a textFrame using javascript

Engaged ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

KarthikSG_0-1648201761223.png

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.appliedParagraphStyle = String(dropdown1.selection);
app.findGrepPreferences.findWhat = "\\r";  
 var foundItems = app.activeDocument.findGrep(true);
app.changeGrepPreferences.changeTo = "";
 app.activeDocument.changeText ( );
 app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

I am trying to remove this end of paragraph symbol(due to this i am getting new empty line)!

TOPICS
How to , 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
Community Expert ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

Your code looks fine. What issue are you seeing? Check if the value of the dropdown selection is correct or not

-Manan

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 ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

Hi Karthic,

try this pattern:

findWhat = "\\r+\\Z";

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

@Laubender this grep is also working! thanks for your response!

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 ,
Mar 26, 2022 Mar 26, 2022

Copy link to clipboard

Copied

But this replaces content. If the paragraph contains any formating, it's more than likely to get messed up. Better to use something like this:

 

// Assuming a story
while (myStory.characters[-1].contents == '\r') {
  myStory.characters[-1].contents = '';
}

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 ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

instead of changeGrep "app.activeDocument.changeGrep ( );",i coded as changeText "app.activeDocument.changeText ( );", Now its working fine! thanks for your response!

 

app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;
app.findGrepPreferences.appliedParagraphStyle = String(dropdown1.selection);
app.findGrepPreferences.findWhat = "\\r";  
app.changeGrepPreferences.changeTo = "";
app.activeDocument.changeGrep( );
app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.NOTHING;

 

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 ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

 

findWhat = "\\r";

 

in combination with:

 

changeTo = "";
app.activeDocument.changeGrep( );

 

 

would remove every end of paragraph character that is formatted with the selected paragraph style in your document. Not only the one that is at the end of a story or at the end of a text cell.

 

Regards,
Uwe Laubender

( ACP )

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 ,
Mar 27, 2022 Mar 27, 2022

Copy link to clipboard

Copied

LATEST

@Laubender Yes, you are absolutely right but it works fine for my purpose! thanks for your time!

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 ,
Mar 25, 2022 Mar 25, 2022

Copy link to clipboard

Copied

Hi @Karthik SG , just to clarify are you trying to remove the paeragraph return or the end of story invisible (#)?

 

Removing the return I would expect this:

 

Screen Shot 8.pngScreen Shot 9.png

 

 

app.findGrepPreferences.findWhat=NothingEnum.NOTHING
app.changeGrepPreferences.changeTo=NothingEnum.NOTHING
app.findGrepPreferences.findWhat = "\\r";
app.changeGrepPreferences.changeTo = "";
app.activeDocument.changeGrep()

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