Text.HTMLtoStyledText
---------------------

Converts HTML to styled text.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Text](component_Text.md) | [15.5](newinversion155.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "Text.HTMLtoStyledText"; HTML { ; Options } ) 

**MBS**( **"Text.HTMLtoStyledText";** /\* Converts HTML to styled text. \*/  
**$HTML**; /\* The html input. \*/   
**$Options**) /\* Optional; The tidy options as JSON object. \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| HTML | The html input. |  |  |
| Options | The tidy options as JSON object. |  | Optional |

### Result

Returns styled text or error.

### Description

Converts HTML to styled text.  
This uses tidy to parse the HTML and then convert the nodes to styled text for FileMaker.  
This way you can preserve bold, italic and other styles as much as possible.  
Does not read style definitions, but only inline styles.  
  
Sets error log, which can be queried with [Text.TidyErrorLog](TextTidyErrorLog.md) function.  
  
For options, check this website:  
[https://api.html-tidy.org/tidy/tidylib\_api\_5.8.0/tidy\_quickref.html](https://api.html-tidy.org/tidy/tidylib_api_5.8.0/tidy_quickref.html)  
  
We support the following html tags:  
- B or STRONG for bold
- I or EM for italic
- U for underline
- S for strikethrough
- SUB for subscript
- SUP for superscript
- FONT with attributes for face, size and color. Color with # hex notation.
- SPAN with CSS styles
- UL and OL for lists with LI for elements.
- BLOCKQUOTE and PRE for passing through text.
- A for links where we print link in \[\]
- IMG for images where we print alt text and reference in \[\]
- H1 to H6 for headers with font size 14 to 24.

For CSS we do font-weight with bold, font-style with italic, text-decoration with underline and line-through, color with hex notation, font-size and font-family.  
  
This is a limited implementation aimed to handle the output of our [Markdown](component_MarkDown.md) functions and to work without a Webviewer.  
### Examples

Convert HTML to styled text:

 Set Field \[ MarkDown::StyledText ; MBS ("Text.HTMLtoStyledText"; MarkDown::HTML ) \]  
\# show in webviewer to compare   
Set Variable \[ $r ; Value: MBS ( "[WebView.LoadHTML](WebViewLoadHTML.md)"; "web"; MarkDown::HTML ) \]  
Convert markdown to styled text:

 Set Variable \[ $id ; Value: MBS ("[MarkDown.Create](MarkDownCreate.md)"; MarkDown::InputMarkDown ) \]  
If \[ MBS ("IsError") \]  
 Show Custom Dialog \[ $id \]  
 Exit Script \[ Text Result: \]  
End If  
Set Variable \[ $html ; Value: MBS ("[MarkDown.HTML](MarkDownHTML.md)"; $id ) \]  
Set Variable \[ $css ; Value: MBS ("[MarkDown.CSS](MarkDownCSS.md)"; $id ) \]  
Set Variable \[ $r ; Value: MBS ("[MarkDown.Release](MarkDownRelease.md)"; $id ) \]  
Set Variable \[ $htmldocument ; Value: "&lt;html&gt;" &amp; ¶ &amp; "&lt;head&gt;" &amp; ¶ &amp; $CSS &amp; ¶ &amp; "&lt;/head&gt;" &amp; ¶ &amp; "&lt;body&gt;" &amp; ¶ &amp; $html &amp; ¶ &amp; "&lt;/body&gt;" &amp; ¶ &amp; "&lt;/html&gt;" \]  
Set Field \[ MarkDown::HTML ; $htmldocument \]  
\# now convert to styled text   
Set Field \[ MarkDown::StyledText ; MBS ("Text.HTMLtoStyledText"; MarkDown::HTML ) \]  
\# show in web viewer to compare   
Set Variable \[ $r ; Value: MBS ( "[WebView.LoadHTML](WebViewLoadHTML.md)"; "web"; MarkDown::HTML ) \]  
Convert bold text:

 MBS ("[Text.Styles](TextStyles.md)"; MBS ( "Text.HTMLtoStyledText"; "&lt;b&gt;bold&lt;/b&gt;"))  
<small>  
Example result:   
\[ { "hasColor" : false, "hasFont" : false, "hasSize" : false, "hasFace" : true, "face" : 256 , "bold" : true, "italic" : false, "underline" : false, "outline" : false, "shadow" : false, "condense" : false, "extend" : false, "strikethrough" : false, "smallCaps" : false, "superscript" : false, "subscript" : false, "wordUnderline" : false, "doubleUnderline" : false, "text" : "bold" , "start" : 1 } \] </small>### See also

- [IsError](IsError.md)
- [MarkDown.Create](MarkDownCreate.md)
- [MarkDown.CSS](MarkDownCSS.md)
- [MarkDown.HTML](MarkDownHTML.md)
- [MarkDown.Release](MarkDownRelease.md)
- [MarkDown.StyledText](MarkDownStyledText.md)
- [Text.Styles](TextStyles.md)
- [Text.TextToHTML](TextTextToHTML.md)
- [Text.Tidy](TextTidy.md)
- [Text.TidyErrorLog](TextTidyErrorLog.md)

### Release notes

- **Version 16.0**
    - Changed [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) to add return after DIV element.
    - Fixed handling of block elements for [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) function.
    - Fixed [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) to show DEL tag as strikethrough.
- **Version 15.5**
    - Added [MarkDown.StyledText](https://www.mbsplugins.eu/MarkDownStyledText.shtml) using [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) to convert HTML to styled text.
    - Added [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) function.
    - Implemented [WebView.GetFormattedText](https://www.mbsplugins.eu/WebViewGetFormattedText.shtml) for Windows using [Text.HTMLtoStyledText](https://www.mbsplugins.eu/TextHTMLtoStyledText.shtml) internally.

### Example Databases

- [Utility functions/MarkDown](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Utility%20functions/MarkDown.shtml#3ScriptAnchor_)

### Blog Entries

- [MBS FileMaker Plugin, version 16.0pr5](https://www.mbsplugins.de/archive/2026-01-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.6pr3](https://www.mbsplugins.de/archive/2025-12-15/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.6pr1](https://www.mbsplugins.de/archive/2025-12-01/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [New in MBS FileMaker Plugin 15.5](https://www.mbsplugins.de/archive/2025-11-25/New_in_MBS_FileMaker_Plugin_15/monkeybreadsoftware_blog_filemaker)
- [Neues MBS Plugin 15.5 für Claris FileMaker](https://www.mbsplugins.de/archive/2025-11-18/Neues_MBS_Plugin_155_für_Clar/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin 15.5 for Claris FileMaker](https://www.mbsplugins.de/archive/2025-11-18/MBS_Plugin_155_for_Claris_File/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.5pr4](https://www.mbsplugins.de/archive/2025-10-16/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)
- [MBS FileMaker Plugin, version 15.5pr3](https://www.mbsplugins.de/archive/2025-10-13/MBS_FileMaker_Plugin_version_1/monkeybreadsoftware_blog_filemaker)

Created 11st October 2025 , last changed 15th October 2025

  
[Text.HTMLtoJSON](TextHTMLtoJSON.md) - [Text.IdentifyData](TextIdentifyData.md)

[HTML Version](TextHTMLtoStyledText.shtml)