Jump to content

Nobreak function and Ampersand problem


thomas.cronqvist

Recommended Posts

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

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

  • 10 months later...

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!

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...