twiggrav

Grav/Twig - Filter summary to remove markdown format


I want to use {{ page.summary }} as summary for front page index of posts. However I find that summary delivers Markdown, so if the post begins with a header:

 # Header 1

 Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
 Quisque aliquam erat velit, ut semper mauris cursus consectetur. 
 Maecenas auctor vitae sapien vel porta. Orci varius natoque 
 penatibus et magnis dis parturient montes, nascetur ridiculus mus. 
 In eu turpis a lorem malesuada feugiat in id mi. Vivamus convallis dui

I will get a properly formatted Header 1 while I would like to have the summary in regular plain text.

Is there any twig filter to do that?


Solution

  • There is no native filter/function but you can surely find some bundle

    https://github.com/aptoma/twig-markdown

    {% markdown %}
    This is a list that is indented to match the context around the markdown tag:
    
    * List item 1
    * List item 2
        * Sub List Item
            * Sub Sub List Item
    
    The following block will be transformed as code, as it is indented more than the
    surrounding content:
    
        $code = "good";
    
    {% endmarkdown %}