5

When doing editing, in certain places I find difficulties to format codes those are within Numbering and Bullets.

Example is this. What I did was cut and paste the line which needs code formatting to the last and the coded section was added somewhat separately. That cannot apply for the instances where sequence is important.

One solution is to add it within ``. It is not suitable when few lines are available.( also < code >)

Is there any way to do this ?

0

1 Answer 1

3

I found the solution in this Meta Stack Overflow question:

For example, if it is a numbered (or bulleted) section which should be like this:

  1. [LINE 1]
  2. [LINE 2]

    Normal [LINE 2] text

    CODE LINE 1
    CODE LINE 2
    CODE LINE 3
    
  3. [LINE 3]


Using Proper Markdown (Preferred Method)

It can be done by indenting the code an extra 4 spaces. Indenting it just 4 spaces will only make it part of the list as normal text. The example for above would be:

1. [LINE 1]
2. [LINE 2]

    Normal [LINE 2] text

        CODE LINE 1
        CODE LINE 2
        CODE LINE 3

3. [LINE 3]

Using HTML <tags> (Alternative Method)

Alternatively, it can also be done using HTML tags like so:

1. [LINE 1]
2. [LINE 2] 

    Normal [LINE 2] text

    <pre><code>CODE LINE 1
CODE LINE 2
CODE LINE 3
</code></pre> 
3. [LINE 3] 

Using HTML <tags> should be avoided as much as possible since it becomes difficult to read and comprehend the text when reading from source. Markdown was born to get rid of this weakness by removing all the clutter.

2
  • 4
    I would suggest to use spaces instead of html <tags>. Follow this answer.... That would be following True Markdown and removes all the clutter while reading markdown source...
    – Aditya
    Commented Dec 21, 2013 at 15:05
  • 1
    I agree. Resist the urge to use HTML as much as possible. It clutters posts and makes them harder to read. Markdown is clean and pretty.
    – Seth
    Commented Dec 22, 2013 at 2:00

You must log in to answer this question.