Go Back   MarcomCentral (PTI) and FusionPro User Communities > Software-Related Talk > The JavaScript Library > Formatting Text

Notices

Reply
 
Thread Tools Search this Thread Display Modes
  #11  
Old July 20th, 2016, 03:08 PM
Dan Korn's Avatar
Dan Korn Dan Korn is offline
FusionPro Senior Engineer / Forum Moderator
 
Join Date: Aug 2008
Location: Chicago, IL
Posts: 4,359
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Quote:
Originally Posted by jl_arnold View Post
The PDF does contain smart quotes in both sections, where the white text is 100% correct. This white text uses a plain text form field.

The black text is incorrect.

Downloading the PDF, you will see the text in white has rounded curly quotes. When you zoom in to the black text, it's squared smart quotes. The text color is also black, when it should be 80% black and the font type is Helvetica when it should be Proxima Nova A Light.
It sounds to me like the rule to replace straight quotes with "smart" quotes is working fine (and therefore the original issue/question in this thread is solved/answered), and that you're now describing a separate issue with the formatting of the text. Specifically, one font has "rounded curly quotes" while another has "squared smart quotes." Therefore, I think that if we can get all of the text into the same font (or at least into the same font family), then all the quotes will look basically the same.

It's very hard to determine much about what's going on with the job just from the output, but I suspect that FusionPro is failing to find the requested font at composition time. This could be due to a mismatch between the font in the Rich Text Editor and the fonts collected with the FusionPro job in Acrobat.

The best way to determine for sure what's going on is to look at the composition log (.msg) file from the MarcomCentral composition. All you need to do is find the URL to the output PDF you already downloaded, and replace the ".pdf" at the end of that URL with ".msg" and paste that back into your browser's address bar and press Enter or Go and you should see the log file. There's probably a message in there about the font.
__________________
Dan Korn
FusionPro Developer / JavaScript Guru / Forum Moderator
PTI Marketing Technologies | Printable | MarcomCentral
LinkedIn

I am a not a Support engineer, and this forum is not a substitute for Support. My participation on this forum is primarily as a fellow user (and a forum moderator). I am happy to provide help and answers to questions when I can; however, there is no guarantee that I, or anyone else on this forum, will be able to answer all questions or fix any problems. If I ask for files to clarify an issue, I might not be able to look at them personally. I am not able to answer private messages, emails, or phone calls unless they go through proper Support channels. Please direct any sales or pricing questions to your salesperson or inquiries@marcom.com.

Complex template-building questions, as well as all installation and font questions or problems, should be directed to FusionProSupport@marcom.com. Paid consulting work may be required to fulfill your template-building needs.

This is a publicly viewable forum. Please DO NOT post fonts, or other proprietary content, to this forum. Also, please DO NOT post any "live" data with real names, addresses, or any other personal, private, or confidential data.

Please include the specific versions of FusionPro, Acrobat, and your operating system in any problem reports or help requests. I recommend putting this information in your forum signature. Please also check your composition log (.msg) file for relevant error or warning messages.

Please post questions specific to the MarcomCentral Enterprise and Web-to-Print applications in the MarcomCentral forum. Click here to request access. Or contact your Business Relationship Manager (BRM/CPM) for assistance.

Please direct any questions specific to EFI's Digital StoreFront (DSF) to EFI support.

How To Ask Questions The Smart Way

The correct spellings are JavaScript, FusionPro, and MarcomCentral (each with two capital letters and no spaces). Acceptable abbreviations are JS, FP, and MC (or MCC). There is no "S" at the end of "Expression" or "Printable"! The name of the product is FusionPro, not "Fusion". "Java" is not is not the same as JavaScript.

Check out the JavaScript Guide and JavaScript Reference! FusionPro 8.0 and newer use JavaScript 1.7. Older versions use JavaScript 1.5.

return "KbwbTdsjqu!spdlt\"".replace(/./g,function(w){return String.fromCharCode(w.charCodeAt()-1)});
Reply With Quote
  #12  
Old July 21st, 2016, 05:48 AM
jl_arnold jl_arnold is offline
Regular Contributor
 
Join Date: Jun 2016
Posts: 53
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

I know the font is there, because the Green bar background color in the one composition is the 1st page of a 4 page template. There is a field in the form where the user selects Green, Teal, Purple or Pink. I only edited the Green template with the new code which loses the font. The 2nd PDF with the Teal is simply selecting that page of the template which uses my original rule. Nothing in the template was changed other than the addition of the second smart quote rule.

But the message is found below:

Job started 04:21:28 - 1469100088.
Creator: FusionPro(TM) VDP Producer (API) 9.3.36
Computer Name: SDPFI04
Current working folder: D:\US\ImageServer\bin
Temporary files folder: C:\Users\Public\Documents\PTI\FusionPro\TEMP_1524\
Template File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.dif
Input File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.xml
Job Config File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.cfg
Unknown Tag /p ignored.
Composing record #1, input record 1
Para style <“”> not found
Unknown Tag /p ignored.
Job ended 04:21:29 - 1469100089.
Total Job Time: 1s



I compared the message above to the message created with the Teal bar, and the only difference seems to be that the Green bar had a message with: "Para style <“”> not found". (see below)

Teal composition message:

Job started 04:23:53 - 1469100233.
Creator: FusionPro(TM) VDP Producer (API) 9.3.36
Computer Name: SDPFI04
Current working folder: D:\US\ImageServer\bin
Temporary files folder: C:\Users\Public\Documents\PTI\FusionPro\TEMP_10880 \
Template File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.dif
Input File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.xml
Job Config File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.cfg
Unknown Tag /p ignored.
Composing record #1, input record 1
Unknown Tag /p ignored.
Job ended 04:23:55 - 1469100235.
Total Job Time: 2s
Reply With Quote
  #13  
Old July 21st, 2016, 08:38 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Quote:
Originally Posted by jl_arnold View Post
I know the font is there, because the Green bar background color in the one composition is the 1st page of a 4 page template. There is a field in the form where the user selects Green, Teal, Purple or Pink. I only edited the Green template with the new code which loses the font. The 2nd PDF with the Teal is simply selecting that page of the template which uses my original rule. Nothing in the template was changed other than the addition of the second smart quote rule.

But the message is found below:

Job started 04:21:28 - 1469100088.
Creator: FusionPro(TM) VDP Producer (API) 9.3.36
Computer Name: SDPFI04
Current working folder: D:\US\ImageServer\bin
Temporary files folder: C:\Users\Public\Documents\PTI\FusionPro\TEMP_1524\
Template File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.dif
Input File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.xml
Job Config File: \\sdfsc02.dc.pti.com\tempvol\tmp\vd3j4hiy.cfg
Unknown Tag /p ignored.
Composing record #1, input record 1
Para style <“”> not found
Unknown Tag /p ignored.
Job ended 04:21:29 - 1469100089.
Total Job Time: 1s



I compared the message above to the message created with the Teal bar, and the only difference seems to be that the Green bar had a message with: "Para style <“”> not found". (see below)

Teal composition message:

Job started 04:23:53 - 1469100233.
Creator: FusionPro(TM) VDP Producer (API) 9.3.36
Computer Name: SDPFI04
Current working folder: D:\US\ImageServer\bin
Temporary files folder: C:\Users\Public\Documents\PTI\FusionPro\TEMP_10880 \
Template File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.dif
Input File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.xml
Job Config File: \\sdfsc02.dc.pti.com\tempvol\tmp\dtmwb01p.cfg
Unknown Tag /p ignored.
Composing record #1, input record 1
Unknown Tag /p ignored.
Job ended 04:23:55 - 1469100235.
Total Job Time: 2s
My guess is that the rule is replacing the quotes in your tags with smart quotes as well and FP is having difficulty parsing them. You can add this to your code to change any smart quotes in your tags back to normal quotes:
Code:
var field = Field("Your Field");
field = field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w)/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’");

(field.match(/<[^>]+>/g) || [])
    .filter(function(tag) {
        return /[“”‘’]/.test(tag);
    })
    .forEach(function(find) {
        var replace = find.replace(/[‘’]/g, "'").replace(/[“”]/g,'"');
        field = field.replace(find, replace);
    });

return field;
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #14  
Old July 21st, 2016, 09:25 AM
jl_arnold jl_arnold is offline
Regular Contributor
 
Join Date: Jun 2016
Posts: 53
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Thanks Ste!

Testing this code, I found it works for both Rich Text and plain text form fields, which is very convenient.

There is only one thing I found that does not convert correctly to smart quotes. It's a single quote after a word. This would be used for possessives. For instance:

The Arnolds' house.
I like Texas' weather.


To add this to the existing code, would I add the following:
Code:
.replace(/(\w)'/g, "$1’")

I noticed that the code doesn't convert characters with spaces around it, but that shouldn't be an issue since that shouldn't be used by itself.

Please let me know about fixing a single quote at the end of a word. Thanks!
Reply With Quote
  #15  
Old July 21st, 2016, 10:37 AM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Quote:
Originally Posted by jl_arnold View Post
To add this to the existing code, would I add the following:
Code:
.replace(/(\w)'/g, "$1’")
Sure, you could do it that way. But consider the following:
Code:
var field = "The Arnolds' house is Texas-travelers' \"most frequented\" establishment.";
return field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w)/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’").replace(/(\w)'/g, "$1’");
Quote:
The Arnolds house is Texas travelers “most frequented” establishment.
In the case of two plural possessive words in the same sentence, the single quotes are replaced first so you'd want to make sure you performed that replacement before a pair of single quotes.

Or you could modify your existing regexp to include:
Code:
field = field.replace(/"([^"]*)"/g, "“$1”").replace(/(\w)'(\w*)/g, "$1’$2").replace(/'([^']*)'/g, "‘$1’");
Previously, that particular regexp was looking for a word character (\w) followed by an apostrophe (') followed by a word character in order to consider it a replaceable match. Adding the asterisk (*) modifies the search pattern to be: a word character followed by an apostrophe followed by 0 or more word characters.
Quote:
Originally Posted by jl_arnold View Post
I noticed that the code doesn't convert characters with spaces around it, but that shouldn't be an issue since that shouldn't be used by itself.
Not sure what you mean by that. The code matches single/double quotes followed by anything that's not a single/double quote and replaces it with smart single/double quotes. Spaces are included in the list of characters that aren't single/double quotes so I wouldn't think there would be any issue converting something like the following:
Quote:
" stephen "
stephen
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #16  
Old July 21st, 2016, 01:34 PM
jl_arnold jl_arnold is offline
Regular Contributor
 
Join Date: Jun 2016
Posts: 53
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Score! I got it!

I modified your code slightly because I couldn't get it working for every quote I was testing. I basically broke the rules apart to replace quotes before and after words separately.


Here is my code in it's entirety for future reference. As you mentioned before there are likely instances not covered by this rule, but this converted a correctly for the text that follows:

Code:
function replaceFunction(field)
{
field = field.replace(/(\w+)"/g, "$1”").replace(/"(\w*)/g, "“$1").replace(/(\w)'(\w+)/g, "$1’$2").replace(/'(\w+)/g, "‘$1").replace(/(\w*)'/g, "$1’");


(field.match(/<[^>]+>/g) || [])
    .filter(function(tag) {
        return /[“”‘’]/.test(tag);
    })
    .forEach(function(find) {
        var replace = find.replace(/[‘’]/g, "'").replace(/[“”]/g,'"');
        field = field.replace(find, replace);
    });

return field;
}

if (Field("Body") != "")
    return replaceFunction(Rule("BodyFont"))
    else
    return "";

Quote:
"test" 'test'
'Please's' "Tests" 'Test'
"Please's" 'Test' "Tests"
"Test" 'Test' "Test"
Test's Tests'. This is 5'6"
'Test of this good stuff.'
Test "says this IS now right.
Correct 'direction for this quote'? = YES!

Thanks for the help!! I would never have gotten this without you two!

- Jason
Reply With Quote
  #17  
Old August 31st, 2017, 12:33 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

One of the instances not covered in this JavaScript rule is class abbreviations. For example:

Code:
John “Smitty” Smith, class of ’81
The rule above would incorrectly return:

Code:
John “Smitty” Smith, class of ‘81
So I added the code in red below to handle class abbreviations:

Code:
function SmartQuotes(field)
{
field = field.replace(/(\w+)"/g, "$1”").replace(/"(\w*)/g, "“$1").replace(/(\w)'(\w+)/g, "$1’$2").replace(/'(\w+)/g, "‘$1").replace(/(\w*)'/g, "$1’").replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3');


(field.match(/<[^>]+>/g) || [])
    .filter(function(tag) {
        return /[“”‘’]/.test(tag);
    })
    .forEach(function(find) {
        var replace = find.replace(/[‘’]/g, "'").replace(/[“”]/g,'"');
        field = field.replace(find, replace);
    });

return field;
}
But it is only catching the first instance of a class abbreviation. Not the second or third, etc. For example:

Code:
John “Smitty” Smith, class of ’81 and Jane Doe, class of ‘82
Any idea's as to what I'm doing wrong?

Thank you.
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
  #18  
Old August 31st, 2017, 10:52 PM
step's Avatar
step step is offline
Senior Contributor
 
Join Date: Jan 2010
Location: Charlotte, NC
Posts: 955
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

I believe the issue is:
Code:
.replace(/(\u2018)([0-9]{2}[^\u2019]*)(\u2018([^0-9]|$)|$|\u2019[a-z])/ig, '\u2019$2$3');
That's capturing (as $2) two digits followed by 0 or more characters that aren't closing single quotes. So it ends up capturing the entire line.

If you're looking for classes specifically, why not make it a little easier on yourself and just add a little context to your regexp:
Code:
return SmartQuotes('John "Smitty" Smith, class of \'81, Jane Doe, class of \'82')
    .replace(/(class of )\u2018(\d{2})\b/gi, '$1\u2019$2');
__________________
Ste Pennell
FusionPro VDP Creator 9.3.15
Adobe Acrobat X 10.1.1
Mac OS X 10.12

LinkedIn
Reply With Quote
  #19  
Old September 1st, 2017, 12:29 PM
David Miller David Miller is offline
Senior Contributor
 
Join Date: Oct 2008
Location: Wallingford, CT
Posts: 263
Default Re: Smart Quotes in Rich Text Editor and Plain Text Editor

Quote:
Originally Posted by step View Post
If you're looking for classes specifically, why not make it a little easier on yourself and just add a little context to your regexp:
Code:
return SmartQuotes('John "Smitty" Smith, class of \'81, Jane Doe, class of \'82')
    .replace(/(class of )\u2018(\d{2})\b/gi, '$1\u2019$2');
Thank you Step. That would be easier. Unfortunately, the data has instances where "class of " is not present. Only the 2-digit year.
__________________
David Miller
FusionPro VDP Creator 10.0.26
Adobe Acrobat Pro 2019.008.20074
Suitcase Fusion 20.0.0 (7653)
macOS High Sierra 10.13.6
Reply With Quote
Reply

Tags
smart quotes, typography

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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