0

I should be able to excerpt from a post like this in a jinja template.

{{post['content']|markdown | truncate(489)}}

Is there a way to show the first paragraph of the post as an excerpt.

Posts are stored in mongodb as markdown files.

Update : The code snippet which @davidism points out makes exactly what I would like to do.

  • did you already see this http://flask.pocoo.org/snippets/19 ? – PRMoureu Oct 17 '17 at 20:23
  • I use Flask-Markdown extension for this library. May be at first glance I should convert it to html `html = markdown.markdown(post[0]['content'])` and than pull the first paragraph using Beautiful Soup. –  Oct 17 '17 at 20:34
  • what's your goal, you need the first paragraph, even if it contains 2000 characters ? otherwise you can use truncate or slice the text before you render the template – PRMoureu Oct 17 '17 at 20:40
  • Sure I try to show the first paragraph of a post on index or /posts page even if contains a lot of characters. Here is an [example](http://www.erdem.tk/arduino) but it was coded with D. –  Oct 17 '17 at 20:45

0 Answers0