thomas.cronqvist Posted September 29, 2015 Share Posted September 29, 2015 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? function NoBreak(s) { return NormalizeEntities(s).replace(/ /g, " "); } return NoBreak(Field("title")); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 29, 2015 Share Posted September 29, 2015 Try this: function NoBreak(s) { return s.replace(/ /g, " ").replace(/ /g, " "); } return NoBreak(TaggedDataField("title")); Quote Link to comment Share on other sites More sharing options...
tobarstep Posted September 29, 2015 Share Posted September 29, 2015 It seems like maybe you have not checked the box "Treat returned strings as tagged text" in the rule editor window. Quote Link to comment Share on other sites More sharing options...
thomas.cronqvist Posted September 29, 2015 Author Share Posted September 29, 2015 Thanks for your replies.. @Dan, your suggestion has exactly the same result - the "&" input composes to & 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? Quote Link to comment Share on other sites More sharing options...
step Posted September 29, 2015 Share Posted September 29, 2015 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: function NoBreak(s) { return s.replace(/&/g,'&').replace(/ /g, " "); } return NoBreak(TaggedDataField("title")); Or maybe: function NoBreak(s) { return RawTextFromTagged(s).replace(/&/g,'&').replace(/ /g, " "); } return NoBreak(TaggedDataField("title")); Quote Link to comment Share on other sites More sharing options...
Dan Korn Posted September 29, 2015 Share Posted September 29, 2015 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. 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. Quote Link to comment Share on other sites More sharing options...
thomas.cronqvist Posted September 30, 2015 Author Share Posted September 30, 2015 @step, the code below did the trick - ampersands shows correctly in DSF! 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! Quote Link to comment Share on other sites More sharing options...
MeeshKB Posted August 18, 2016 Share Posted August 18, 2016 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! Quote Link to comment Share on other sites More sharing options...
step Posted August 18, 2016 Share Posted August 18, 2016 Glad to hear it, Michelle! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.