How to indent a few lines in Markdown markup?

后端 未结 22 630
予麋鹿
予麋鹿 2020-12-12 08:42

I want to write a few lines of text. They should be formatted normally except each line should start at the 6th column. I.e. I don\'t want the code block formatting rule to

相关标签:
22条回答
  • 2020-12-12 09:08

    One of the problems with starting your line with non-breaking spaces is that if your line is long enough to wrap, then when it spills onto a second line the first character of the overflow line with start hard left instead of starting under the first character of the line above it.

    If your system allows you to mix HTML in with your markdown, a cheep and cheerful way of getting an indent is like this:

    <ul>
    My indented text goes here, and it can be long and wrap if you like.
    And you can have multiple lines if you want.
    </ul>
    

    Semantically within your HTML it is nonsense (a UL section without any LI items), but all browsers I have used just happily indent what's between those tags.

    0 讨论(0)
  • 2020-12-12 09:08

    For completeness, the deeper bulleted lists:

    Nested deeper levels: ---- leave here an empty row * first level A item - no space in front the bullet character * second level Aa item - 1 space is enough * third level Aaa item - 5 spaces min * second level Ab item - 4 spaces possible too * first level B item

    Nested deeper levels:

    • first level A item - no space in front the bullet character
      • second level Aa item - 1 space is enough
        • third level Aaa item - 5 spaces min
      • second level Ab item - 4 spaces possible too
    • first level B item

      Nested deeper levels:
       ...Skip a line and indent eight spaces. (as said in the editor-help, just on this page)
      * first level A item - no space in front the bullet character
       * second level Aa item - 1 space is enough
           * third level Aaa item - 5 spaces min
          * second level Ab item - 4 spaces possible too
      * first level B item
      
              And there
              could be even more
              such octets of spaces.
      
    0 讨论(0)
  • 2020-12-12 09:10

    One way to do it is to use bullet points, which allows you specify multiple levels of indentation. Bullet points are inserted using multiples of two spaces, star, another space Eg.:

    this is a normal line of text
      * this is the first level of bullet points, made up of <space><space>*<space>
        * this is more indented, composed of <space><space><space><space>*<space>
    

    This method has the great advantage that it also makes sense when you view the raw text.

    If you care about not seeing the bullet points themselves, you should (depending on where you're using markdown) to be able to add li {list-style-type: none;} to the css for the whole mark down area.

    0 讨论(0)
  • 2020-12-12 09:10

    Use a no-break space directly   (not the same as !).

    (You could insert HTML or some esoteric markdown code, but I can think of better reasons to break compatibility with standard markdown.)

    0 讨论(0)
  • 2020-12-12 09:12

    Suprisingly nobody came up with the idea of just using a div with paddingyet, so here you go:

    <div style="padding-left: 30px;">
    My text
    </div>
    
    0 讨论(0)
  • 2020-12-12 09:13

    Some Markdown implementations seem to use the ~ character for indentation.

    0 讨论(0)
提交回复
热议问题