Shortening HTML content python / django

hanselx

New Member
I have a system that pulls HTML content from a database which could look like this:\[code\]<p>This is some text</p><p>More text</p><p>Third Paragraph</p>\[/code\]and when displaying it, it displays a short summary of the blog post content but right now when displaying the text, I have set a limit of characters to a number like 200 and it will cause the summary to like this:\[code\]<p>This is some text</p><p>More text</\[/code\]Cutting off the content at any place, potentially destroying the rest of the webpage.Is there a way in python to either close all opened tags or to only get a certain number of top-level blocks? For instance, 2 blocks would be the first two \[code\]<p></p>\[/code\] tags. I have seen word press have this feature when displaying short previews of articles.
 
Back
Top