Nov 02, 2012; 08:55
Brian Beer
[FMPro] Unbolding Paragraph Marks
Ok, this has me stumped. I have two text fields (FMPA 11, mac) one with a table-of-contents that has bolded header and sub header lines, a second that uses a custom function to calculate simple html from the first. The tables-of-contents are usually pasted in from word documents, and the bold formatting stretches across paragraph breaks. This results in poorly formed html like: "<p><b>Contents</p><p></p><p></b>". That </b> really should be nested inside the first set of p tags.
If I go to the text field and select the paragraph breaks and cmd-shift-b, I get the proper code: "<p><b>Contents</b></p><p></p>"
What I'd like to do is use an auto enter (or stand alone) calculation to fix this, but I can't seem to get it to work.
So far I've tried:
Substitute( TOC; "=B6"; TextFormatRemove ( "=B6" )
Substitute( TOC; "\=B6"; TextFormatRemove ( "\=B6" )
Substitute( TOC; "=B6"; TextStyleRemove ( "=B6"; Bold )
Substitute( TOC; "\=B6"; TextStyleRemove ( "\=B6"; Bold )
Any other ideas?
Probably irrelevant, but here's the CustomFunction:
/*
Overview:
---------
Wrap any bold text in the input text with <b> tags, and italic text with <em> tages: =91plain <b>bold</b> <em>italic</em> <b><em>both</b></em>=92
Author:
-------
2012-07-18 Brian Beer
Based entirely on (copied from) BoldItalicEncode ( Text ) <http://www.briandunning.com/cf/709>
By:
2006-11-25 Tom Robinson <http://www.tomrobinson.co.nz/>
2007-09-20 Fix when running under v9 (thanks to Orlando Antonio S=E1nchez for bringing to my attention and initial investigation)
*/
Substitute(
/*
1. Convert the text to CSS
2. Prepare for execute by encoding quotes
3. Each line generated has a trailing ampersand (ready for the next line), so at the end we add a null string
*/
/* The code we=92re generating uses:
w=whole text
p=position of =91>=92
s=style portion of text
t=text portion of text
b=bold flag
i=italic flag
*/
"<p>" &
Evaluate(Substitute(GetAsCSS(Text);
["\"";"\\\""];
["<SPAN STYLE= ";"Let([w=\""];
["</SPAN>";"\";
p=Position(w;\">\";1;1);
s=Left(w;p-2);
t=Right(w;Length(w)-p);
b=PatternCount(s;\"font-weight: bold\");
i=PatternCount(s;\"font-style:italic\")];
Choose(2*b+i;\"\";\"<em>\";\"<b>\";\"<b><em>\")&t&Choose(2*b+i;\"\";\"</em>\";\"</b>\";\"</b></em>\"))&"])&"\"\"");
/* Now change <BR> to </p><p> */
["<BR>";"</p><p>"]
) & "</p>"
Thanks,
Brian
Brian H. Beer
Advertising Manager and Direct Mail Coordinator
Penn State University Press
820 North University Drive
USB 1, Suite C
University Park, PA 16802
814-865-1327
FAX: 814-863-1408
http://www.psupress.org
Shop our Religious Studies Book Sale!
Now through November 30th
Save 50-75% on over 200 titles!
http://www.psupress.org/ReligiousStudiesSale12.html
Brian H. Beer
Advertising Manager and Direct Mail Coordinator
Penn State University Press
820 North University Drive
USB 1, Suite C
University Park, PA 16802
814-865-1327
FAX: 814-863-1408
http://www.psupress.org
Shop our Religious Studies Book Sale!
Now through November 30th
Save 50-75% on over 200 titles!
http://www.psupress.org/ReligiousStudiesSale12.html
Brian H. Beer
Advertising Manager and Direct Mail Coordinator
Penn State University Press
820 North University Drive
USB 1, Suite C
University Park, PA 16802
814-865-1327
FAX: 814-863-1408
http://www.psupress.org
Shop our Religious Studies Book Sale!
Now through November 30th
Save 50-75% on over 200 titles!
http://www.psupress.org/ReligiousStudiesSale12.html
#############################################################
This message is sent to you because you are subscribed to
the mailing list FMPro
FMPro@lists.lassosoft.com
To unsubscribe, E-mail to: <FMPro-unsubscribe@lists.lassosoft.com>
Send administrative queries to <FMPro-request@lists.lassosoft.com>