6

I was writing a question in which I used a list to indicate the steps my code takes, immediately followed by the code. Like this:

  • Foo the bar
  • bar the foo

    Foo = bar / 12 bar = 6 / Foo

Albeit being properly indented with four spaces and two newlines inbetween the list and the code this doesn't work. As a work around I can add a <br> tag in between like this:

  • Foo the bar
  • bar the foo


Foo = bar / 12
bar = 6 / Foo

But this requires three blank lines between the list and the codeblock. Can we please make markdown respect two new lines as being the end of the list?

ps. I know there are a lot of bug reports about this, but this is a feature-request.

  • Use the best text editor in the world: :se ts=4, Enter, V3j> – iBug Aug 7 at 8:41
6

Treating a double newline specially is not how Markdown works.

To terminate a list or other indented Markdown content, you can use an empty comment instead. For example:

 -  foo
 -  bar

<!-- -->

    code { block }

which renders as:

  • foo
  • bar
code { block }
  • 1
    I know that it's not how it works, hence the [feature-request] as IMO it should work like that. – Luuklag Aug 7 at 8:09
4

Use fences rather than indenting code blocks:

- Foo the bar
- bar the foo

```
Foo = bar / 12 bar = 6 / Foo
```
  • Foo the bar
  • bar the foo

Foo = bar / 12 bar = 6 / Foo

  • That certainly can be an option, but if I copy already indented code it becomes a horrible mess of double indention. – Luuklag Aug 7 at 7:48
  • 2
    The {} editor button (or Ctrl+K) can also un-indent selected blocks if each line is already consistently indented with 4 spaces. @Luuklag – Byte Commander Aug 7 at 12:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .