markdown-formatter icon indicating copy to clipboard operation
markdown-formatter copied to clipboard

Autoformat incorrectly adding spaces in code fence

Open ddejohn opened this issue 4 years ago • 3 comments

Before formatting:

After formatting:

ddejohn avatar Aug 27 '20 15:08 ddejohn

The code block must have an explicit life language type, like

``` python
output = check_age('Adrian',22)
print(output)
```

sumnow avatar Jan 12 '21 08:01 sumnow

  1. You've missed the point. Notice in the first screenshot, there is no trailing whitespace after the codefence for the unhighlighted and Python code blocks both. The autoformatter added whitespace in the second screenshot.
  2. There are plenty of times where you would want to use a plain code block without syntax highlighting.

ddejohn avatar Jan 12 '21 17:01 ddejohn

@sumnow Can we reopen this issue? The problem is that markdown code like this:

``` python
print(5)
```

Should be formatted like this

```python
print(5)
```

That is, there should not be a space between the three backticks and the language type. It should be ```python instead of ``` python. See the examples in the Mastering Markdown article. This autoformatter is adding whitespace that shouldn't be there.

jackfirth avatar May 02 '21 23:05 jackfirth