MD046 assumes block indents are bad if they are a part of lists.
See original GitHub issueDescription
MD046 incorectly flags all fenced code blocks as violations even if they are a part of lists.
Motivating example:
1. Here is my list item
```bash
# example code
```
2. Here is my next list item.
which I expect to render as follows:
-
Here is my list item
# example code
-
Here is my next list item.
The vscode markdownlint extension flags this as a violation of MD046 but if I follow the advice on the MD046 wiki page then I get the following rendering:
Example following MD046 advice:
1. Here is my list item
```bash
# example code
``` <!-- space added here to prevent rendering errors in comment-->
2. Here is my next list item.
Rendered result:
- Here is my list item
# example code
- Here is my next list item.
which is not how I want the list to appear in its rendered form.
Possible Resolutions:
It seems like there are two approaches that could be used to fix this issue:
- broaden MD046 to allow for these cases when in lists. (both formations are valid so it probably just needs to be disabled when immediately following list items (ordered or unordered)
- Allow the visual studio code extension to ignore specific violations.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Code block style [Expected: indented; Actual: fenced]
I 'm assuming your are using the markdownlint plugin for VSCode. ... you desire, I will note that there are multiple options for...
Read more >Markdownlint Rules
Note: This rule applies to a sublist only if its parent lists are all also unordered (otherwise, extra indentation of ordered lists interferes...
Read more >Implement ```-style (fenced) Markdown code blocks
Fenced code blocks are like Markdown's regular code blocks, except that they're not indented and instead rely on a start and end fence...
Read more >Indenting C Programs
Selection Statements: IF, IF-ELSE, and SWITCH. In this section, I present a variety of code examples to demonstrate how to indent various forms...
Read more >IndentationError: expected an indented block
In most popular programming languages, spaces or indentation are just used to make the code look better and be easier to read. In...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@MichaIng Your failing test run reports an issue with
docs/dietpi_tools.md
, but your example and link are for a different file.Looking at the reported file, we see code fences on lines 7 and 17, so the report of an indented code block on line 27 being inconsistent is correct.
https://github.com/MichaIng/DietPi-Docs/blame/b9ac99eab398f0b850eac7460ea8267f06bf0c4e/docs/dietpi_tools.md
Many thanks for mentioning
CommonMark
, good to know there is such a specification, only sad that Python-Markdown core + standard library extensions do not fulfil it completely (e.g. fenced code in list items is not possible) so that pymdownx needs to be used for that, while other extensions of pymdownx are not part of CommonMark. Not a real issue but that makes it difficult for newcomers to differentiate between common/specified syntax that is usually interpreted correctly and uncommon syntax where one has to expect failures of code quality/syntax tests 😅.But all fine, I see that these content tabs a very uncommon and conflict with some header and thematic break syntax. So the effort to implement support is likely too large effort to be reasonable.