htmlcsstwigmarkdowngrav

How to center text with Markdown?


How do you center an item with Markdown? I'm looking for a solution that works in Grav.


Solution

  • Markdown does not support this feature natively, but you can achieve this wrapping Markdown into HTML.

    As a rule of thumb, most 'flavors' of Markdown will render this as centered text:

    <p style="text-align: center;">Centered text</p>
    

    Specifically for Grav, as their documentation states, you should do these following steps:

    in your system configuration file user/config/system.yaml make sure to activate the markdown extra option:

    pages:
      markdown:
        extra: true
    

    in your wrapper tag make sure to add the parameter markdown="1" to activate processing of markdown content:

    <div class="myWrapper" markdown="1">
    # my markdown content
    
    this content is wrapped into a div with class "myWrapper"
    </div>