Brian Dunning's FileMaker Custom Functions

CSStoFMText_cf ( text )

Converts CSS inline styles to FileMaker Pro Text

  Average rating: 4.4 (41 votes) Log in to vote

Christopher Gauntt   Christopher Gauntt - Show more from this author
Cordega Solutions

Share on Facebook Share on Twitter

  Sample input:
Let's see how it converts back.
  Sample output:

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

This takes CSS styled text and converts it back to FileMaker Pro formatting.

Note: If you are not converting a field directly, don't forget to put the \ before the quote if you are embedding the tags into a calculation.



David Wikström   David Wikström, Vancouver, BC
Aug 24, 2009
This is a great custom function. However, when I copy-paste it, I get an error message saying "too many parameters...".
There's also a typo on the name of the function - the comment says CSStoFMText but the recursive call uses cscf_CSStoFMText.

I got the cf to work by adding an extra end-parenthesis just before the comment

// converts the text string between the span tags into the filemaker conversions from the above
Christopher Gauntt   Christopher Gauntt, Cordega Solutions
May 15, 2010
I finally got around to fixing it. Sorry for the ridiculously long delay. I didn't even know there was a problem until one of my colleagues found the function and the comment.
Peter F.   Peter F., Zurich
Dec 31, 2010
I convert GetAsCSS(field) back
I needed an additional Substitute(field," ¶","") . (that's substitute space newline with empty)

Thank you for the very helpful function CSSToFMText and Happy New Year 2011.
Mike   Mike, Taipei
Jan 19, 2011
Nice little function. Ive been working on building text editor functions into a FM database am trying to find a slick way to get formatted text into a MS word document. This kind of thing is helpful and may form part of the solution

One small bug:

"Strikethrough" is "Line-through" in CSS land.

Also It doesn't handle chinese characters. A must in this corner of the world.

Peter van Herk   Peter van Herk, Brisbane, Australia
Jul 16, 2015
I had to add the following for it to successfully render the line breaks.

Key changes are lower case line break and added extra substitute for <br/>

Here is the change and addition. Works just fine now in FM14 and thanks heaps.

// swaps out breaks with FileMaker return markers
; $_Text = Substitute ( $_TextSpan ; "<br>" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<br/>" ; "¶" )
Alec   Alec, Brooklyn
Dec 1, 2016
Regarding your comment, Peter. The Substitute function is case sensitive and there is sometimes a space before the forward slash. So the full list should be:

// swaps out breaks with FileMaker return markers
; $_Text = Substitute ( $_TextSpan ; "<br>" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<br/>" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<br />" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<BR>" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<BR/>" ; "¶" )
; $_Text = Substitute ( $_TextSpan ; "<BR />" ; "¶" )

Or, the nested version:

$_Text =
Substitute (
[ "<br>" ; "¶" ];
[ "<br/>" ; "¶" ];
[ "<br />" ; "¶" ];
[ "<BR>" ; "¶" ];
[ "<BR/>" ; "¶" ];
[ "<BR />" ; "¶" ];

Same goes for the Substitute function at the top as well.

Log in to post comments.


Note: these functions are not guaranteed or supported by Please contact the individual developer with any questions or problems.

Support this website.

This library has been a free commmunity resource for FileMaker users and developers for 15 years. It receives no funding and has no advertisements. If it has helped you out, I'd really appreciate it if you could contribute whatever you think it's worth:

Under construction. Email me your wish list for improvements.