Formatting HTML tags in string

Hello, I need to format a string received from an API. The string contains HTML tags and needs to be converted into text while preserving the appropriate formatting according to the tags. Usually I’d use the Format String or CKEditor widgets to do that, but in this specific case the data widget is a gallery (changing it to a list view will generate other issues) and these widgets aren’t supported in gallery.   So far what I’ve been trying to do is converting the data in a nanoflow (or microflow) and then displaying it, I’ve tried a few community commons Java actions but none of them convert the string to follow the HTML tags, and now I’m trying to write a custom JS action to handle the data but haven’t been successful so far, I’ve only been able to convert it to plain text, which isn’t ideal.   To exemplify what I need to do is, I receive data like this:  <p>Some text.</p><p><strong>More text.</strong> </p><div>Even more text.</div> And I need it to be formatted like this: Some text. More text. Even more text.   This is the code that I’ve been using in case it helps: export async function JS_FormatString(stringToFormat) { // BEGIN USER CODE // Create a temporary container element to parse the HTML const container = document.createElement("div"); container.innerHTML = stringToFormat; // Extract the text content from the parsed HTML const formattedText = container.textContent; // Display the formatted text console.log(formattedText); return formattedText; // END USER CODE   Thanks in advance, and if my question is unclear, please let me know, and I will do my best to clarify any doubts.
1 answers

 Hi Marcel,


did you try the HTML Element widget? It’s great to display this type of data.

This is the documentation about it.


let me know if it works :)