How to remove p tags from contentfragment multiline text using java | Community
Skip to main content
Level 2
May 28, 2022
Solved

How to remove p tags from contentfragment multiline text using java

  • May 28, 2022
  • 2 replies
  • 2082 views

I have a content fragment with multiline text field as one of the element in it. When I give any description in that, it is storing inside <p> tag and &nbsp(for blank spaces). I want to store this contentElement as a json alogng with other content fragment elements.

How can i pass this multiline text to backend java ignoring these <p> and &nbsp tags. Below is screenshot of how the multiline text is getting saved in CRX. Need help on this

 

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SantoshSai

Hi @mayursatav @parthibanselvam 

From the above article removeSingleParagraphContainer attribute was for the Classic UI and deprecated.

As per my understanding, there isn’t anything OOTB available that can remove the p single paragraph container tag, to achieve this, one can deal with Sling Model.

Perfect Reference: https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-removesingleparagraphcontainer-for-touch-ui

Regards,
Santosh

2 replies

SantoshSai
Community Advisor
Community Advisor
May 28, 2022

Hi @parthibanselvam 

 

Why do you want to store data in JSON format? If your intention is to expose data in JSON format eventually - that is OOTB. 

Have a look at below few links

1. https://experienceleague.adobe.com/docs/experience-manager-learn/sites/content-fragments/content-fragments-delivery-feature-video-use.html?lang=en

2. https://m.youtube.com/watch?v=al7k9c81lTM

3. https://www.aemtutorial.info/2017/06/aem-content-fragment-output-as-json.html?m=1

 

However, if you still wants to customize it you can do it by extending content fragments for more details please visit this article 

https://experienceleague.adobe.com/docs/experience-manager-65/developing/extending-aem/customizing-content-fragments.html?lang=en

Similar requirement: https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager/p-tag-removal-from-text-components/td-p/194197

 

Hope that helps you!

 

Regards,

Santosh

 

 

Santosh Sai
MayurSatav
Community Advisor and Adobe Champion
Community Advisor and Adobe Champion
May 29, 2022

hi @parthibanselvam ,

 

Please check the below solution, I hope it will solve your problem.

 

https://stackoverflow.com/questions/17965276/disable-auto-adding-of-p-tag

 

SantoshSai
Community Advisor
SantoshSaiCommunity AdvisorAccepted solution
Community Advisor
May 30, 2022

Hi @mayursatav @parthibanselvam 

From the above article removeSingleParagraphContainer attribute was for the Classic UI and deprecated.

As per my understanding, there isn’t anything OOTB available that can remove the p single paragraph container tag, to achieve this, one can deal with Sling Model.

Perfect Reference: https://sourcedcode.com/blog/aem/aem-richtext-remove-p-tag-removesingleparagraphcontainer-for-touch-ui

Regards,
Santosh

Santosh Sai