How to add empty spaces in MD markdown readme on GitHub?

I am trying to add empty spaces before the line starts to make my GitHub README.md look something like this:

enter image description here

Right now it looks like this:

enter image description here

I tried adding a tag <br/> to fix the beginning of a new line, now it works, but I don’t understand how to add spaces before the beginning of a line without changing everything to &nbsp; Maybe there is a more elegant way to format it?

+30
source share
5 answers

You can use <pre> to display all the spaces and spaces that you typed. For instance:.

 <pre> hello, this is just an example .... </pre> 
+31
source

Markdown really changes everything so that html and html squeeze spaces, so you really can't do anything about it. For this you need to use &nbsp; . A ridiculous example that I write in markdowns and I will use a couple here.

Above is &nbsp; without backlinks

+21
source

Markdown is converted to HTML / XHMTL .

John Gruber created Markdown in 2004, in collaboration with Aaron Swartz, on syntax, to give people the ability to write using easy-to-read and write simple text format and, if desired, convert it to structurally valid HTML (or XHTML ).

HTML is entirely based on &nbsp; to add extra spaces if it does not define / use JavaScript or CSS for elements.

Markdown is a lightweight markup language with plain text formatting syntax. It is designed so that it can be converted to HTML and many other formats using a tool with the same name.


If you want to use "

  1. only one space "either use &nbsp; or just press Spacebar (2nd is a good choice in this case)

  2. more than one space "use &nbsp; + space (for 2 consecutive spaces)


eg. If you want to add 10 spaces in a row, then you should use

&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;

&nbsp; space &nbsp; space &nbsp; space &nbsp; space &nbsp; space

instead of using 10 &nbsp; one by one as below

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;


For more details check

  1. Adding multiple spaces between text in Markdown ,
  2. How to create extra space in HTML or web page .
+15
source

I am surprised that everyone refers to inextricable spaces ( &nbsp; ), but no one mentioned HTML entities for two or four spaces ( &ensp; and &emsp; respectively). If you want to quickly accumulate horizontal empty space, this is more efficient.

  1. &nbsp;
  2. &ensp;
  3. &emsp;
+1
source

As a workaround, you can use a code block to literally render the code. Just surround your text with triple quotation marks. '' ' It will look like this:

2018-07-20 Wrote this answer Can format it without &nbsp; Also don't need <br/> for new line

Note that using <pre> and <code> you get a slightly different behavior:   and <br/> will be parsed, not inserted literally.

<pre>:

  2018-07-20 Wrote this answer
            Can format it without 
     Also don't need 
for new line

<code>: 2018-07-20 Wrote this answer Can format it without Also don't need
for new line
2018-07-20 Wrote this answer Can format it without Also don't need
for new line
2018-07-20 Wrote this answer Can format it without Also don't need
for new line
2018-07-20 Wrote this answer Can format it without Also don't need
for new line
2018-07-20 Wrote this answer Can format it without Also don't need
for new line

0
source

Source: https://habr.com/ru/post/1269304/


All Articles