When a Java code snippet is added to Markdown, the indentation is not formatted correctly. For example, having the following code snippet:
```java
if(x==0){
if(flag){
return true;
}else{
return false;
}
}
```
will render the following once the auto-formatter is complete
```java
if(x==0){
if(flag){
return true;
}else{
return false;
}
}
```
I am certain that this is a part of the language of Java's settings because replacing ```java
with just ```
will keep the format as usual.
How can I ensure to have IntelliJ format Java code snippets appropriately in Markdown (or ignore autoformat and I would format them myself)?
This is caused by the fact that partial code snippets are not supported yet. See https://youtrack.jetbrains.com/issue/IDEA-267081
As a workaround, uncheck the Preferences | Languages & Frameworks | Markdown | Inject languages in code fences option:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With