kcoleglobalprinting.com Posted October 14, 2010 Posted October 14, 2010 My client wants curly quotes rather than straight quotes on a document. I have written the following script to use the html tags &ldquo and &rdquo to force the double quote character to be used. var MyVar = Field("Title"); (html = "“"); (html = "”"); MyVar = MyVar.replace("*", "“"); MyVar = MyVar.replace("**", "”"); return MyVar;In the data file, I placed a single asterisk (*) in front of each value and a double asterisk (**) behind each value. This rule should replace the asterisks with the quotes. However, nothing shows up when I preview or compose. Here's where it gets interesting, if I replace &ldquo and &rdquo with another html tag such as ™ for the trade mark TM symbol, this shows up when I compose. I am using the Typeface Futura Std Condensed, which as far as I can tell, does contain smart quote glyphs. FusionPro 5.8, Acrobat 8.1, Windows XP.
esmith Posted October 14, 2010 Posted October 14, 2010 I'm not savvy enough to know what the 2nd and 3rd lines in your code snippet are doing, but the way I read your replace functions, you would only replace the first instance of both a single and double asterisk. For a similar issue, I had to use the regular expression model to replace all instances globally in my data. (Keep in mind that if you go this route, the global nature of the first replace would also replace a double asterisk with two "“" codes... Assuming you are remembering to use the "treat as tagged" checkbox (which I assume you are since the TM code seems to work for you), I would expect your code to work for one instance. Have you tried using the "’" code just to see if single quotes work as well?
Dan Korn Posted October 14, 2010 Posted October 14, 2010 There are several issues with your rule. First, and most importantly, those aren't the right entities. The correct entities, as listed in the FusionPro Tags Reference Guide, and in the entity.def file, are "„" and "”" (with an "r" at the end of each entity name). I'm not sure where the entities you're using came from, but FusionPro has a very specific set of built-in entities that it knows about, which are not necessarily the same as standard HTML entities. You need to refer to the documentation. Second, you're only replacing one instance of each quote. If the field contains more than one quotation (i.e. more than one pair of quotes), you'll miss any after the first. You can use a regular expression with the "g" flag in the String.replace call to replace all occurrences (or you can use FusionPro's built-in ReplaceSubstring function). Of course, you'll also need to replace the double asterisks before the single asterisks; otherwise, if you replace the double asterisks first, each pair will be replaced by a pair of left quotes. Third, you really should use TaggedTextFromRaw (or NormalizeEntities in versions of FusionPro prior to 6.0) to ensure that any existing XML-like control characters (such as ampersand and less-than) are properly converted for the tagged markup string you're returning. Finally, this code doesn't seem to do anything useful: (html = "“"); (html = "”");Anyway, to resolve all of these issue, I think you want to do this: return NormalizeEntities(Field("Title")).replace(/\*\*/g, "”").replace(/\*/g, "„");
Recommended Posts
Archived
This topic is now archived and is closed to further replies.