MarcomCentral (PTI) and FusionPro User Communities

MarcomCentral (PTI) and FusionPro User Communities (http://forums.pti.com/index.php)
-   Formatting Text (http://forums.pti.com/forumdisplay.php?f=32)
-   -   Nobreak function and Ampersand problem (http://forums.pti.com/showthread.php?t=4345)

thomas.cronqvist September 29th, 2015 11:57 AM

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"));


Dan Korn September 29th, 2015 12:58 PM

Re: Nobreak function and Ampersand problem
 
Try this:
Code:

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


tobarstep September 29th, 2015 01:02 PM

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.

thomas.cronqvist September 29th, 2015 01:51 PM

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?

step September 29th, 2015 02:55 PM

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"));


Dan Korn September 29th, 2015 03:02 PM

Re: Nobreak function and Ampersand problem
 
Quote:

Originally Posted by thomas.cronqvist (Post 17542)
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 (Post 17542)
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.

thomas.cronqvist September 30th, 2015 01:33 AM

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!

MeeshKB August 18th, 2016 10:55 AM

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!

step August 18th, 2016 11:00 AM

Re: Nobreak function and Ampersand problem
 
Glad to hear it, Michelle!


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

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