Home > Software engineering >  IntelliJ - Formatting Java code in Markdown
IntelliJ - Formatting Java code in Markdown

Time:03-17

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)?

CodePudding user response:

This is caused by the fact that partial code snippets are not supported yet. See enter image description here

  • Related