I am looking for a way to automatically create an abstract, basically the first few sentences / paragraphs of a blog entry, to display articles (which are written in markdown) in the list. I am currently doing something like this:
def abstract(article, paras=3):
return '\n'.join(article.split('\n')[0:paras])
just to grab the first few lines of text, but I'm not quite happy with the results.
What I'm really looking for is to finally get 1/3 of the screen of the formatted text that will be displayed in the list of records, but using the above algorithm, the number of popped ends up with wildly different amounts, since it's a bit like a line or two, often mixed with essays of a more ideal size.
Is there a library that is good at this? if not, do you have suggestions for improving the output?
source
share