Jump to content

Losing ampersand using all caps rule


dougiann

Recommended Posts

In an address line, I need the type to go to all caps, yet when doing this I lose all the special characters (ampersands, etc.)...I see on the forum that this is a known problem, yet I don't know how to program in J.S. so I need help. What do I do? I'm using the pre-formatted JS rules in FP for <allcaps> for the specific field...thanks for any help...
Link to comment
Share on other sites

You need to use the NormalizeEntities function on "raw" text when it's in a rule with the "Treat returned strings as tagged text" box checked. Otherwise, there's no way for FusionPro's internal tag parser to know that you intend for an ampersand to be typeset literally instead of denoting an XML entity.

 

Basically, anywhere in your "Treat returned strings as tagged text" rule where you're calling the Field function, you should wrap that in a call to NormalizeEntities. For example, instead of this:

return '<uppercase>' + Field("Name") + '</uppercase>';

You should do this:

return '<uppercase>' + NormalizeEntities(Field("Name")) + '</uppercase>';

 

The other option is to let JavaScript handle the uppercase conversion, like so:

return Field("Name").toUpperCase();

In which case you can UNcheck the "Treat returned strings as tagged text" box.

 

I can't give you more specific advice about what to change in your rule unless you post the syntax.

Link to comment
Share on other sites

  • 3 months later...
You need to use the NormalizeEntities function on "raw" text when it's in a rule with the "Treat returned strings as tagged text" box checked. Otherwise, there's no way for FusionPro's internal tag parser to know that you intend for an ampersand to be typeset literally instead of denoting an XML entity.

 

Basically, anywhere in your "Treat returned strings as tagged text" rule where you're calling the Field function, you should wrap that in a call to NormalizeEntities. For example, instead of this:

return '<uppercase>' + Field("Name") + '</uppercase>';

You should do this:

return '<uppercase>' + NormalizeEntities(Field("Name")) + '</uppercase>';

The other option is to let JavaScript handle the uppercase conversion, like so:

return Field("Name").toUpperCase();

In which case you can UNcheck the "Treat returned strings as tagged text" box.

 

I can't give you more specific advice about what to change in your rule unless you post the syntax.

 

Hi Dan,

I was trying to add the NormalizeEntities(Field("Name")) function to the Javascript version of the all caps rule but I can not figure out where to add the function.

The prebuilt rule is converted to:

 

Var1="Title";

CaseSelection="allcaps";

 

if(CaseSelection == "allcaps")

 

return ToUpper(Field(Var1));

 

if(CaseSelection == "smallcaps")

 

return "<smallcap>" + Field(Var1) + "</smallcap>";

 

if(CaseSelection == "propercase")

 

return ToTitleCase(Field(Var1));

 

if(CaseSelection == "lowercase")

 

return ToLower(Field(Var1));

 

Will you tell me where to add NormalizeEntities(Field("Name")) in this rule?

Also in another post you suggested that NormalizeEntities(Field("Name")) should be added to all return fields. Does that mean I should add it to the fields that return phone numbers in my BC?

I am using Fusion Pro designer 5.8P2c on a Mac for web to print.

Thank you for your help,

Leslie

Vertis Communications Phoenix

Link to comment
Share on other sites

All you need to do to fix the problem is to uncheck the "Treat returned strings as tagged text" box. That's it. You don't need to edit the logic at all.

 

That said, the entire rule's logic reduces to this:

return ToUpper(Field("Title"));

Hypothetically, if you were to leave the "Treat returned strings as tagged text" box checked, then the place to add the call to NormalizeEntities would be around any call to the Field function, like so:

return ToUpper(NormalizeEntities(Field("Title")));

Basically, if that box is checked, then you need to make sure that you use NormalizeEntities for any text which might contain characters such as ampersands and less-than symbols, which would trip up the tagged markup parser. If the box is unchecked, then you need to make sure to NOT use NormalizeEntities, or else you'll see actual entities such as & in your output.

Also in another post you suggested that NormalizeEntities(Field("Name")) should be added to all return fields. Does that mean I should add it to the fields that return phone numbers in my BC?

It's highly unlikely that phone numbers are going to contain symbols such as ampersands and less-than signs which would be affected by NormalizeEntities, so, no, I wouldn't worry about it for those fields.

Link to comment
Share on other sites

  • 7 months later...

Hi Dan,

 

I've been having this same problem and have tried both of your suggestions....

 

I used the standard case selection rule while UNchecking "Treat returned strings as tagged text"

 

and I tried this rule with the "treat returned strings as tagged text" checked:

return '<uppercase>' + NormalizeEntities (Field("Title")) + '</uppercase>';Field("Title")

 

Both ways I get "&AMP; AMP;" when I type and ampersand in the online template. Can someone tell me what I'm doing wrong.

 

thanks!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...