prettier / prettier-vscode

Visual Studio Code extension for Prettier
https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode
MIT License
5.14k stars 454 forks source link

Markdown - Ignore block of code snippet #1584

Closed jd-solanki closed 3 years ago

jd-solanki commented 3 years ago

summary

I want to preserve the line just before the comment in the code snippet of my markdown file

Github Repository to Reproduce Issue

I don't think we need github repo link

Steps To Reproduce:

  1. Paste below code in markdown file and set syntax as vue(I am unable to nest code snippets).
  2. Save (which will format the file and will remove the blank line above comment)

Expected result

Its a markdown. I have used vue as wrapper for below code snippet but I am unable to nest code snippet in code snippet.

<template>
  <some-tag>

    <!-- Slot & Using slotProps -->
    <template #my-slot="slotProps">

      <!-- Custom Content -->
      <div class="d-flex justify-content-between">
      </div>

    </template>

    <router-view />
  </some-tag>
</template>

Actual result

<template>
  <some-tag>
    <!-- Slot & Using slotProps -->
    <template #my-slot="slotProps">
      <!-- Custom Content -->
      <div class="d-flex justify-content-between"></div>
    </template>

    <router-view />
  </some-tag>
</template>

Is it required?

Additional information

I also tried using <!-- prettier-ignore-start --> but didn't worked

VS Code Version: 1.49.2

Prettier Extension Version: 5.7.1

OS and version: Linux Mint 20

Prettier Log Output

["INFO" - 7:51:42 pm] Detected local configuration (i.e. .prettierrc or .editorconfig), VS Code configuration will not be used
["INFO" - 7:51:42 pm] Using config file at '/home/jd/Projects/clevision/vuesax-vuejs-admin-template/.prettierrc.json'
["INFO" - 7:51:42 pm] Prettier Options:
{
  "filepath": "/home/jd/vue-template/docs/development/layout.md",
  "parser": "markdown",
  "useTabs": false,
  "tabWidth": 2,
  "arrowParens": "avoid",
  "bracketSpacing": true,
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": true,
  "printWidth": 120,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": false,
  "singleQuote": true,
  "trailingComma": "all",
  "vueIndentScriptAndStyle": false
}
["INFO" - 7:51:42 pm] Formatting completed in 22.955046ms.
ntotten commented 3 years ago

This is how prettier formats html. See: https://prettier.io/playground/#N4Igxg9gdgLgprEAuEAeeBbADgGwIbwB8AOlAARmoDOEGcAtDHgOYlSkUWoCE99ZAZRwQYZAGRkAqlQCWUZmSrCYABQBOELFTJ82nSplwE4ZAMQYAnvSUiAvMRA3VGrQ7Yd9lXvwDCAVyoYWjIfaHhYHXo9T1QAExkANzIwfCoqexBY+gAzHDgADzIAKwCYGWyrSFgEGHoAIzgYAHc4BDcPfVQAeniE93JObsN8IlIOyg0-eDV6BJk4JrIu6O6aOkYWNiG4bBG4QhAAGhBNMugqZFA8NQ0mlWuEC5Q8HCa8CwvjurU8MABrRoCLC-OTMZAwNR+ODHHYNWKxOCxAAyeHkfhYcAAYhA1BgCGV5MgQHgphAjiAABYwDA4ADqFJk8CowLAcAEj0ZiUZFiJYDS5LkVDgamcLDxyGyLyFxyKVHyACEfv9AXg6Ei5HAJVLoSBZfkBKC8gBFPwiTVISU4aUgYFqIVqIkJKHkrBqOQwWkyWIwCnIAAcAAZjq6IELaT8sETXXB7QlNccAI6m+DqTRPYlUehQVoI2LktRwJMyAvqMV4LVWnVCjAycGQquGuAms0V61MOqe72+pAAJmOELwMhwoNCGHFKBjAFZyQE4AAVPB1J6W61OuAASSgCNgAjAbqwMAAgluBDALHlW3AAL5XoA

jd-solanki commented 3 years ago

Hi @ntotten then why <!-- prettier-ignore-start --> is not working in my markdown file, am I doing something wrong?

I tried wrapping my code snippet in the above comment but it is still formatted by prettier.

Thanks for your time.

Regards.

jlongo commented 3 years ago

I'm also trying to ignore block of code in htm file with <!-- prettier-ignore-start --> and <!-- prettier-ignore-end -->

Not working at all.

This

<!-- prettier-ignore-start -->
description = "xxxxxxxxxxxx" 
[cookieConsent] 
message = "Este espaço utiliza \"cookies\" para melhorar a sua experiência de navegação." 
dismiss = "Concordo" 
learnMore = "Informações adicionais" 
link = "/informacao-sobre-cookies" 
theme = "dark-bottom" 
[SeoCmsPage] 
==
<!-- prettier-ignore-end -->

is transformed in:

<!-- prettier-ignore-start -->
description = "xxxxxxxxxxxx" [cookieConsent] message = "Este espaço utiliza \"cookies\" para
melhorar a sua experiência de navegação." dismiss = "Concordo" learnMore = "Informações adicionais" link =
"/informacao-sobre-cookies" theme = "dark-bottom" [SeoCmsPage] ==
<!-- prettier-ignore-end -->

TIA JL

github-actions[bot] commented 3 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.