Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MD046/code-block-style: Code block style [Expected: indented; Actual: fenced]

I am trying some documentation for my workspace but this error is bugging me more than expected.

  • if i need to define my code block style then where?

  • Or this is something I need to enable or update settings in my VS Code? as i am using VS Code to create this markup file.

enter image description here

like image 481
aatif shaikh Avatar asked May 22 '26 09:05

aatif shaikh


1 Answers

The simple solution is to just leave the default setting and edit your Markdown to always use the same style of code blocks consistently throughout. After all, that is the point of a linter. To encourage consistent, well-formed Markdown.

But, of course, you may want to change the default. I'm assuming your are using the markdownlint plugin for VSCode. As stated in the documentation:

Rules can be enabled, disabled, and customized by creating a JSON file named .markdownlint.jsonc/.markdownlint.json or a YAML file named .markdownlint.yaml/.markdownlint.yml or a JavaScript file named .markdownlint.js in any directory of a project.

You can create one of the above files at the root of your project, and customize the behavior as you desire. As you don't state what behavior you desire, I will note that there are multiple options for Rule MD046.

  1. consistent (default): Whichever style is found first is enforced for every code block. In other words, all code block must be either indented or fenced. You can't mix them.
  2. fenced: All code blocks must be fenced. Any indented code blocks will raise an error.
  3. indented: All code blocks must be indented. Any fenced code blocks will raise an error.
  4. false: Disable the rule and allow either or both styles of code blocks. Mix or match at will.

If you are using a YAML file, it might look like this:

MD046: fenced

Just swap out fenced for the option you prefer.

like image 139
Waylan Avatar answered May 26 '26 18:05

Waylan