Shopify / prettier-plugin-liquid

Prettier Liquid/HTML plugin
https://npm.im/@shopify/prettier-plugin-liquid
MIT License
94 stars 15 forks source link

prettier-ignore-start / -end not respected in markdown files #206

Closed BernhardBln closed 10 months ago

BernhardBln commented 10 months ago

Describe the bug prettier-ignore-start / -end not respected in markdown files.

Unformatted source

# Title

<!-- prettier-ignore-start -->
<!-- TOC -->
* [Title](#title)
  * [Nested 1.1](#nested-11)
  * [Nested 1.2](#nested-12)
    * [Nested 1.2.1](#nested-121)
<!-- TOC -->
<!-- prettier-ignore-end -->

## Nested 1.1

xxx

## Nested 1.2

xxx

### Nested 1.2.1

xxx

Expected output See unformatted source.

Actual output

# Title

<!-- prettier-ignore-start -->
<!-- TOC -->

- [Title](#title)
  - [Nested 1.1](#nested-11)
  - [Nested 1.2](#nested-12) \* [Nested 1.2.1](#nested-121)
    <!-- TOC -->
    <!-- prettier-ignore-end -->

## Nested 1.1

xxx

## Nested 1.2

xxx

### Nested 1.2.1

xxx

Debugging information

Apache Maven 3.9.4 (dfbb324ad4a7c8fb0bf182e6d91b0ae20e3d2dd9) Java version: 11.0.2, vendor: Oracle Corporation OS name: "mac os x", version: "10.16", arch: "x86_64", family: "mac"

Just create some empty directory somewhere, and create in there one file Readme.md with the unformatted source from above, and a pom.xml file with this content:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <groupId>org.example</groupId>
  <artifactId>untitled</artifactId>
  <version>1.0-SNAPSHOT</version>

  <build>
    <plugins>
      <plugin>
        <groupId>com.diffplug.spotless</groupId>
        <artifactId>spotless-maven-plugin</artifactId>
        <version>2.39.0</version>
        <configuration>
          <formats>
            <format>
              <includes>
                <include>*.md</include>
              </includes>
              <prettier>
                <prettierVersion>3.0.2</prettierVersion>
              </prettier>
            </format>
          </formats>
        </configuration>
      </plugin>
    </plugins>
  </build>
</project>

pom.xml and Readme.md should be next to each other. Inside of this directory, run mvn spotless:apply

Additional Context If the <-- TOC --> comments are the problem - they are part of the generated TOC (I'm using IntelliJ to create/update the TOC), so I cannot remove them.

charlespwd commented 10 months ago

Hi, it seems like this was reported on the wrong repo. This is for Liquid+HTML. You might be looking for prettier/prettier.

BernhardBln commented 10 months ago

You are right, sorry for this.

Whoever stumbles over this, the solution/workaround is to add a newline before prettier-ignore-end.