Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove spacing before list in Markdown

Tags:

markdown

I have the following Markdown string:

`log-level` (optional)<br>
Sets the minimal log level messages need in order to be printed to stdout.

Allowed values:
- `debug`
- `warning`
- `error` (default)

GitHub as well as Stack Overflow render it like this (blockquote added for visual distinction):

log-level (optional)
Sets the minimal log level messages need in order to be printed to stdout.

Allowed values:

  • debug
  • warning
  • error (default)

(screenshot from GitHub)


As visible here and in the screenshot, the Markdown renderer adds spacing between the last paragraph ("Allowed values") and the first list item.

Checking the generated HTML shows why:

<p><code>log-level</code> (optional)<br>
Sets the minimal log level messages need in order to be printed to stdout.</p>
<p>Allowed values:</p>
<ul>
<li><code>debug</code></li>
<li><code>warning</code></li>
<li><code>error</code> (default)</li>
</ul>

The text "Allowed values" is placed in an own <p> tag, and there is a margin between the <p> and the following <ul>.


Is there a way to reduce or get rid of that space, such that it roughly matches the space between list items?

like image 244
janw Avatar asked Jun 21 '26 19:06

janw


1 Answers

This may not be exactly what you are looking for, but there is no way that I know of to do what you're asking. A possible workaround to this would be to make your list a sub-list by adding an equal amount of spaces to sub-bullets. See below:

`log-level` (optional)<br>
Sets the minimal log level messages need in order to be printed to stdout.

- Allowed values:
  - `debug`
  - `warning`
  - `error` (default)

log-level (optional)
Sets the minimal log level messages need in order to be printed to stdout.

  • Allowed values:
    • debug
    • warning
    • error (default)
like image 152
Skwid Avatar answered Jun 24 '26 07:06

Skwid



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!