Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to center text with Markdown?

How do you center an item with Markdown? I'm looking for a solution that works in Grav. I can't find anything on the internet, and I'm getting a bit frustrated.

like image 917
KylianMbappe Avatar asked Nov 21 '18 19:11

KylianMbappe


People also ask

How do I center align text?

Select the text that you want to center. in the Page Setup group, and then click the Layout tab. In the Vertical alignment box, click Center. In the Apply to box, click Selected text, and then click OK.

How do I change alignment in markdown?

The Best Answer is Aligning text in native markdown is not possible. However, you can align the text using inline HTML tags. To justify, replace right with justify in the above.

How do I center align an image in markdown?

Solution 2 : use the "align" deprecated attribute This is not recommended, but in some cases this is the only way to center the image. Insert this HTML snippet into your markdown file. You can also try to put the "align" attribute directly into the "img" tag.


2 Answers

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>
like image 76
Estevan Maito Avatar answered Oct 21 '22 12:10

Estevan Maito


For me it worked with the following hack: adding the tag div on top without closing the div tag. This makes the entire markdown centralized

<div align="center">
like image 36
Fernando_Akistapace Avatar answered Oct 21 '22 10:10

Fernando_Akistapace