Jump to content

jl_arnold

Registered Users - Approved
  • Posts

    53
  • Joined

Everything posted by jl_arnold

  1. Thanks Dan! With this single line of code, I replaced my original 8 lines for the rule associated to the plain text editor. I have found this doesn't work 100% with the rich text editor. The quotes are converting to the curly smart quotes, but it's not applying the font. The font type seems to be unicode character. The font I'm using is very much a rounded curly quote, which appears when entering text in a plain text field. But in the Rich Text Editor, the quotes appear blocky and not rounded. I tried editing the code by using the markup entities, such as "’". I used RawTextfromTagged("rsquor;") + "$1" + RawTextfromTagged("’") but that did not fix the issue with the font style of the quotes. Can you also provided this code for the Rich Text Editor? Thanks!
  2. How can I write that I only want to change an apostrophe if it's surrounded by other letters? I'm guessing the any character code is $ but I'm not sure. would it be field = field.replace(/\$'$(?=[\w|$])/g, "’");
  3. I am having issues with perfecting this smart quote javascript. I have a template using both plain and rich text. I have successfully gotten the smart quotes to show in the correct direction a majority of the time. One issue is when an apostrophe is used as the first character in the field, both in a plain text and rich text field. The second issue is when quotes the first character in the rich text editor only. My code is: Rich Text Rule function replaceFunction(field) { // replace quotes at the beginning or end of the entire string first field = field.replace(/^\"(?=[\w|$][^<>]*<)/, "&ldquor;"); field = field.replace(/^\'(?=[\w|$][^<>]*<)/, "&lsquor;"); field = field.replace(/\"$(?=[^<>]*<)/, "&rdquor;"); field = field.replace(/\'$(?=[^<>]*<)/, "&rsquor;"); // now replace quotes before or inside words field = field.replace(/\s"(?=[\w|$][^<>]*<)/g, " &ldquor;"); field = field.replace(/\s'(?=[\w|$][^<>]*<)/g, " &lsquor;"); // finally, replace all other quotes (after words) field = field.replace(/\"(?=[^<>]*<)/g, "&rdquor;"); field = field.replace(/\'(?=[^<>]*<)/g, "&rsquor;"); return field; } if (Field("Body") != "") return replaceFunction(Feild("Body")) else return ""; Plain Text Rule function replaceFunction(field) { // replace quotes at the beginning or end of the entire string first field = field.replace(/^\"/, "&ldquor;"); field = field.replace(/^\'/, "&lsquor;"); field = field.replace(/\"$/, "&rdquor;"); field = field.replace(/\'$/, "&rsquor;"); // now replace quotes before or inside words field = field.replace(/\s"(?=[\w|$])/g, " &ldquor;"); field = field.replace(/\s'(?=[\w|$])/g, " &lsquor;"); // finally, replace all other quotes (after words) field = field.replace(/\"/g, "&rdquor;"); field = field.replace(/\'/g, "&rsquor;"); return field; } if (Field("Headline") != "") return replaceFunction(Field("Headline")) else return ""; I tested modifying the codes a few ways but don't really know how to right the correct fix. I added a line to the "now replace quotes before or inside words" but wasn't able to get it right exactly. During testing, I could add the following line to the replace quotes before or inside words to fix the double quotes: field = field.replace(/\"(?=[\w|$][^<>]*<)/g, "&ldquor;"); , but I can't do this for the single quote because it changes the direction of an apostrophe (&rsquor;) to a left single quote. Can someone help me as I am not very good at creating javascript code? Thanks!
×
×
  • Create New...