Your AssistView control doesn't support line breaks in the answer...

Hi, I'm returning line breaks which work fine in any other .net maui control I use, listview with a template, etc.  But when I use your AssistView, it completely ignores the line breaks.  Please put a request in to get this resolved in a future version. Line breaks in iOS/Android make the AI result look much more polished.

Screenshot for reference.  You can see how line breaks are ignored in the AssistView, but the same content over in the SfListView are not ignored.  Disregard the question mark. I'm doign some 


Attachment: IMG_7240_643f1050.PNG

2 Replies

MB Michael Brown November 16, 2025 05:01 AM UTC

I figured it out. iOS assist view handles HTML features just fine. Windows/Android are unix format /n/r, etc. I have AI format everything in html, then I just convert back to Unix with a helper method where applicable.


/// <summary>
/// Normalizes HTML content to plain text with proper line breaks and bullet points for the current platform.
/// </summary>
/// <remarks>Converts HTML tags like <br>, <ul>, and <li> to platform-appropriate text formatting.
/// On iOS/Mac, uses zero-width spaces to prevent line break collapsing. On other platforms, uses standard newlines.</remarks>
/// <param name="text">The HTML text to normalize.</param>
/// <returns>The normalized text with line breaks and bullet points that render consistently across platforms.</returns>
public static string NormalizeFromHtml(this string text)
{
    if (string.IsNullOrEmpty(text))
        return text;


    // Replace <br> and <br/> and <br /> tags with newlines
    text = System.Text.RegularExpressions.Regex.Replace(text, @"<br\s*/?>", "\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


    // Replace </li> with newline to separate list items
    text = System.Text.RegularExpressions.Regex.Replace(text, @"</li>", "\n", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


    // Replace <li> with bullet point
    text = System.Text.RegularExpressions.Regex.Replace(text, @"<li>", "• ", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


    // Remove <ul> and </ul> tags
    text = System.Text.RegularExpressions.Regex.Replace(text, @"</?ul>", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


    // Remove all remaining HTML tags
    text = System.Text.RegularExpressions.Regex.Replace(text, @"<[^>]+>", "", System.Text.RegularExpressions.RegexOptions.IgnoreCase);


    // Decode common HTML entities
    text = text.Replace(" ", " ");
    text = text.Replace("&", "&");
    text = text.Replace("<", "<");
    text = text.Replace(">", ">");
    text = text.Replace(""", "\"");
    text = text.Replace("'", "'");
    text = text.Replace("'", "'");


    // Replace various line break formats with a consistent format
    text = text.Replace("\r\n", "\n"); // Windows -> Unix
    text = text.Replace("\r", "\n"); // Old Mac -> Unix


    return text;
}


MM Muthukumar Madasamy Syncfusion Team replied to Michael Brown November 17, 2025 01:21 PM UTC

Hi Michael Brown,

Thank you for your input. Your solution is correct, converting HTML to platform-appropriate plain text and normalizing line breaks is indeed a valid approach, especially given the current behavior of SfAIAssistView across platforms.

If you need any assistance or have further suggestions, feel free to reach out anytime.


Best Regards,

Muthu Kumar Madasamy.


Loader.
Up arrow icon