Forum Discussion

Gursimrat's avatar
Gursimrat
Leader
11 years ago

Rich text not coming through, any alternative for this?

I am creating a widget which pulls through all the recent activity for the commnity via recent threads API. This is working fine for the plain text but I just checked it with putting in some images and smileys in the replies, but it did not show up.

 

The response body in the xml is, only orange text below came in the response, but where the img tag starts, it didn't show up in the page where I am pulling it. is there any way I can skip the images via ftl? or any other alternatives? I want if there is any image, it should skip it and print the text only. Is is doable in FTL?

 

<body type="string">
<P>Hello Varun, this is a nice blog post, <STRONG>lets us</STRONG> <img class="emoticon emoticon-catindifferent" id="catindifferent" src="/smilies/16x16_cat-indifferent.png" alt=":catindifferent:" title="Cat Indifferent" />of <FONT size="4" color="#FF0000">this captures </FONT></P> <div class="lia-spoiler-container"><a class="lia-spoiler-link" href="xyz.stage.lithium.com/#" rel="nofollow">Spoiler</a><noscript> (Highlight to read)</noscript><div class="lia-spoiler-border"><div class="lia-spoiler-content">style</div><noscript><div class="lia-spoiler-noscript-container"><div class="lia-spoiler-noscript-content">style</div></div></noscript></div></div> <P>&nbsp;</P> <P>as well&nbsp;</P> <P>&nbsp;</P> <P>&nbsp;</P>
</body>

 

5 Replies

  • HaidongG's avatar
    HaidongG
    Lithium Alumni (Retired)
    11 years ago

    map you share the code output the string? did you try 

    ${somestring?html}

     

  • Gursimrat's avatar
    Gursimrat
    Leader
    11 years ago
    This issue is that i have put a limit of 100 characters, and it strips off the first few characters img tag, and it appears as a broken image. I think I need to use regex to handle this so I can skip a the tags and skip to the next text.
  • Gursimrat's avatar
    Gursimrat
    Leader
    11 years ago
    Is it possible to display only text without using regex? Is there a way the returned result is not in HTML format and just displays the plain text so I don't have to use the regex.
  • PaoloT's avatar
    PaoloT
    Lithium Alumni (Retired)
    11 years ago

    Hi,

     

    you can either create and call an endpoint to do the filtering for you using one of the stripping tools provided in the utils context object , or call the rest API directly and implement the HTML stripping logic in your application.

     

    Hope this helps,

  • Gursimrat's avatar
    Gursimrat
    Leader
    11 years ago
    I have used the below regex and this is working fine

    ?replace("<[^>]*>","", "r")

    Do you think this could break?