Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 29th, 2015, 11:57 AM
thomas.cronqvist thomas.cronqvist is offline
Forum n00b
 
Join Date: Sep 2015
Posts: 6
Default Nobreak function and Ampersand problem

Hi,

I have a problem with a piece of code on a business card in DSF/FP9.3. We need to keep a string on one line without wrapping and use the function below. Works fine unless there is a "&" in the input field.

"Me And You" works fine but "Me & You" composes to "Me & You"

Anyone know how to overcome?



Code:
function NoBreak(s)
{
  return NormalizeEntities(s).replace(/ /g, " ");
}
return NoBreak(Field("title"));
Reply With Quote
  #2  
Old September 29th, 2015, 12:58 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,293
Default Re: Nobreak function and Ampersand problem

Try this:
Code:
function NoBreak(s)
{
  return s.replace(/ /g, " ").replace(/ /g, " ");
}
return NoBreak(TaggedDataField("title"));
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #3  
Old September 29th, 2015, 01:02 PM
tobarstep tobarstep is offline
Regular Contributor
 
Join Date: Sep 2008
Location: Florida
Posts: 71
Default Re: Nobreak function and Ampersand problem

It seems like maybe you have not checked the box "Treat returned strings as tagged text" in the rule editor window.
__________________
FusionPro VDP 9.3.12 Desktop/Server
Windows 7 Enterprise / Windows Server 2008 r2
Acrobat X
Reply With Quote
  #4  
Old September 29th, 2015, 01:51 PM
thomas.cronqvist thomas.cronqvist is offline
Forum n00b
 
Join Date: Sep 2015
Posts: 6
Default Re: Nobreak function and Ampersand problem

Thanks for your replies.. @Dan, your suggestion has exactly the same result - the "&" input composes to &

Code:
function NoBreak(s)
{
  return s.replace(/ /g, " ").replace(/ /g, " ");
}
return NoBreak(TaggedDataField("title"));
Both my original function and yours work well in Creator.

@tobarstep - I have checked the "Treat returned strings as tagged text" checkbox. If not checked, all no break spaces would show as   when composing.

I suspect this has to do with how DSF is handing over the text input to FP Server. Would it maybe be possible to convert the entity "&" to a plain text "&" in the script before trying to perform the NoBreak function?
Reply With Quote
  #5  
Old September 29th, 2015, 02:55 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Nobreak function and Ampersand problem

I wonder if the conversion is happening elsewhere in your DSF – prior to the data being processed by the TaggedDataField function. If that were the case, the first ampersand in "&" would be converted to the same entity and give the appearance that it wasn't being properly converted to raw text. With that in mind, you could try to account for that:
Code:
function NoBreak(s)
{
  return s.replace(/&/g,'&').replace(/ /g, " ");
}
return NoBreak(TaggedDataField("title"));
Or maybe:
Code:
function NoBreak(s)
{
  return RawTextFromTagged(s).replace(/&/g,'&').replace(/ /g, " ");
}
return NoBreak(TaggedDataField("title"));
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #6  
Old September 29th, 2015, 03:02 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,293
Default Re: Nobreak function and Ampersand problem

Quote:
Originally Posted by thomas.cronqvist View Post
I suspect this has to do with how DSF is handing over the text input to FP Server.
Yes, it is about how DSF is presenting the data in the data file. Can you actually get that data file that DSF is generating? The path to it should be listed at the start of the composition log (.msg) file.
Quote:
Originally Posted by thomas.cronqvist View Post
Would it maybe be possible to convert the entity "&" to a plain text "&" in the script before trying to perform the NoBreak function?
That's basically what the TaggedDataField function does. It accounts for the fact that the data file generated by DSF (like with MarcomCentral and other web-to-print apps) is tagged markup, while the data used for local FP Desktop/Creator compositions is almost always flat-file, non-tagged data.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #7  
Old September 30th, 2015, 01:33 AM
thomas.cronqvist thomas.cronqvist is offline
Forum n00b
 
Join Date: Sep 2015
Posts: 6
Default Re: Nobreak function and Ampersand problem

@step, the code below did the trick - ampersands shows correctly in DSF!

Code:
function NoBreak(s)
{
  return s.replace(/&/g,'&').replace(/ /g, " ");
}
return NoBreak(TaggedDataField("title"));

Thanks for all your support - I hope to be able to re-contribute at some point!
Reply With Quote
  #8  
Old August 18th, 2016, 10:55 AM
MeeshKB MeeshKB is offline
Regular Contributor
 
Join Date: Jun 2012
Location: Alberta, Canada
Posts: 64
Default Re: Nobreak function and Ampersand problem

Ste, you are the best.

Revisiting my ampersand issues a year later, now that we are moving our clients from Avanti eAccess to EFI DSF. The same solution that worked for Thomas also solved my issues perfectly (as one would expect, since it looks like we're both working in DSF).

Thank you!
__________________
Michelle
Digital Services Coordinator at Rileys (print and electronic services provider) in Alberta, Canada
FusionPro VDP 9.1.0, Windows 7, Acrobat Pro XI , InDesign CS6, Avanti eAccess, EFI Digital Storefront
Reply With Quote
  #9  
Old August 18th, 2016, 11:00 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Nobreak function and Ampersand problem

Glad to hear it, Michelle!
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
Reply

Tags
&, ampersand, dsf, javascript

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:44 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) 2011, PTI Marketing Technologies™, Inc.