I would like to create a typical preview snippet using the [read more] link. The problem is that the content that I would like to use for SubString () contains text and html written by the user with the WYSIWYG editor.
Of course, I check that the string is not empty or empty, and then SubString (), the problem is that I can finish breaking the html tags, discarding the rendering of the whole site.
The WYSIWYG editor does not seem to produce perfectly formatted HTML, and many times it seems to use tags <br />instead <p></p>, etc .... in principle, I cannot rely on well-formed tags, etc ..
My workaround was to simply remove all the HTML and fine-tune the remaining text. This works, but loses any formatting that was in HTML.
What is the best SubString () method in a block of unconfigured HTML while retaining HTML that will not disrupt site rendering?
source
share