How to strip out all of the rich text formatting?
I would like to clean up the rich text formatting from posts on the community in post processing. What is the best approach in doing this?
For example, turn a post like this:
Hello world
To something like this:
Hello World
We can remove the buttons for options but you can still "copy and paste" formatted text or add it via a browser inspector. I assume searching for inline styles would be the best approach, along with anything like <strong>, <b>,<em>, etc... tags that have their own tag to format using a js script that runs after publish. The reason I don't want to entirely remove it is so customers still have the ability to upload a photo, video or link still.
Are you looking to physically strip out the formatting, or would hiding the effects of certain tags be adequate? If it is the latter, you can add inherit!important syling to the lia-message-body class in the CSS:
#lia-body .lia-content .lia-message-body font , strong, b, strike { font: inherit !important; font-family: inherit !important; font-weight: inherit !important; font-size: inherit !important; font-weight: inherit !important; text-decoration: inherit !important; color: inherit !important; }
Thanks to ChaviBonchev for pointing out this little trick.