This document is to share a pair of companion custom functions that I wrote in response to this post:
The functions translate FileMaker rich text content into a format which can be expressed using just plain text. As in the post above, use cases could include any scenario where text formatting needs to be preserved as the data is passed through, or stored in, a system which doesn't naturally or easily support FileMaker's rich text data.
• Though I have been careful to code everything to be platform-agnostic, I have not tested these functions on Windows.
Brief video overview:
Updates To Attached Archive:
01 Sept 2018
Updated archive to address an issue whereby the decoding process would break if either of the following two characters appears in the original rich text:
• 'DOUBLE LOW-9 QUOTATION MARK' (Unicode 201E)
• 'DOUBLE HIGH-REVERSED-9 QUOTATION MARK' (Unicode 201F)
Sincere thanks to hhenle for discovering and reporting this issue.
03 Sept 2018
Added updated archive with new version of CF which supports additional FMP text styles:
This update also provides imperfect support for text styles:
When translating to and from Rich Text, subscript and superscript text will increase by one point size in cases where the original font size is an odd-numbered value. This is due to a rounding effect that happens in the GetAsCSS function. In cases where the original font size is an even-numbered value, or in cases where neither the superscript nor the subscript style has been applied, font size should be properly preserved.
I suspect that I might have originally refrained from adding all of the styles not only out of laziness, but also because including all the possible styles increases the size of the JSON output. For this reason, I am not deleting the previously updated version of the archive which only translates what I considered to be the most common styles at the time when I created the CFs.
Once again, sincere thanks goes to hhenle for motivating this update, providing examples of how it could work, and examples of cases where special adjustments to the code were necessary. Thank you, Hubert!