prettier / prettier-vscode

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

Bug: Bad markdown table formatting #2267

Closed Altair-Bueno closed 2 years ago

Altair-Bueno commented 2 years ago

Summary

Formatting a table does not produce the expected format. It should ignore code blocks pipes, like foo | baz

Steps To Reproduce:

  1. Create a .md file
  2. Create a markdown table that looks like the following
| Foo | Bar |
|-|-|
| ocl Lambda | `self -> count(x| x<> null)` |
| Other | Other |
  1. Format with prettier (Command palette > Format document)
  2. Analize the horrendous output
| Foo        | Bar              |
| ---------- | ---------------- | ---------- |
| ocl Lambda | `self -> count(x | x<> null)` |
| Other      | Other            |

Expected result

| Foo        | Bar                          |
| ---------- | ---------------------------- |
| ocl Lambda | `self -> count(x| x<> null)` |
| Other      | Other                        |

Actual result

| Foo        | Bar              |
| ---------- | ---------------- | ---------- |
| ocl Lambda | `self -> count(x | x<> null)` |
| Other      | Other            |

Additional information

image

VS Code Version: 1.61.2

Prettier Extension Version: v9.0.0

OS and version: macOS Monterey 12.0.1

Prettier Log Output

["INFO" - 6:37:29 PM] Extension Name: esbenp.prettier-vscode.
["INFO" - 6:37:29 PM] Extension Version: 9.0.0.
["DEBUG" - 6:37:29 PM] Enabling Prettier globally
{
  "languageSelector": [
    {
      "language": "javascript"
    },
    {
      "language": "mongo"
    },
    {
      "language": "javascriptreact"
    },
    {
      "language": "typescript"
    },
    {
      "language": "typescriptreact"
    },
    {
      "language": "json"
    },
    {
      "language": "jsonc"
    },
    {
      "language": "json5"
    },
    {
      "language": "css"
    },
    {
      "language": "postcss"
    },
    {
      "language": "less"
    },
    {
      "language": "scss"
    },
    {
      "language": "handlebars"
    },
    {
      "language": "graphql"
    },
    {
      "language": "markdown"
    },
    {
      "language": "mdx"
    },
    {
      "language": "html"
    },
    {
      "language": "vue"
    },
    {
      "language": "yaml"
    },
    {
      "language": "ansible"
    },
    {
      "language": "home-assistant"
    },
    {
      "language": "jsonc",
      "scheme": "vscode-userdata"
    }
  ],
  "rangeLanguageSelector": [
    {
      "language": "javascript"
    },
    {
      "language": "javascriptreact"
    },
    {
      "language": "typescript"
    },
    {
      "language": "typescriptreact"
    },
    {
      "language": "json"
    },
    {
      "language": "graphql"
    }
  ]
}
["DEBUG" - 6:37:40 PM] Using bundled version of prettier.
["DEBUG" - 6:37:40 PM] Enabling Prettier for Workspace /Volumes/Google Drive/Mi unidad/Asignaturas por año/Tercer año/Primer cuatrimestre/Modelado y Diseño del Software
{
  "languageSelector": [
    {
      "pattern": "/Volumes/Google Drive/Mi unidad/Asignaturas por año/Tercer año/Primer cuatrimestre/Modelado y Diseño del Software/**/*.{js,_js,bones,cjs,es,es6,frag,gs,jake,jsb,jscad,jsfl,jsm,jss,mjs,njs,pac,sjs,ssjs,xsjs,xsjslib,wxs,js.flow,jsx,ts,tsx,json,avsc,geojson,gltf,har,ice,JSON-tmLanguage,mcmeta,tfstate,tfstate.backup,topojson,webapp,webmanifest,yy,yyp,jsonc,sublime-build,sublime-commands,sublime-completions,sublime-keymap,sublime-macro,sublime-menu,sublime-mousemap,sublime-project,sublime-settings,sublime-theme,sublime-workspace,sublime_metrics,sublime_session,json5,css,wxss,pcss,postcss,less,scss,handlebars,hbs,graphql,gql,graphqls,md,markdown,mdown,mdwn,mkd,mkdn,mkdown,ronn,scd,workbook,mdx,component.html,html,htm,html.hl,inc,xht,xhtml,mjml,vue,yml,mir,reek,rviz,sublime-syntax,syntax,yaml,yaml-tmlanguage,yaml.sed,yml.mysql}",
      "scheme": "file"
    },
    {
      "language": "javascript"
    },
    {
      "language": "mongo"
    },
    {
      "language": "javascriptreact"
    },
    {
      "language": "typescript"
    },
    {
      "language": "typescriptreact"
    },
    {
      "language": "json"
    },
    {
      "language": "jsonc"
    },
    {
      "language": "json5"
    },
    {
      "language": "css"
    },
    {
      "language": "postcss"
    },
    {
      "language": "less"
    },
    {
      "language": "scss"
    },
    {
      "language": "handlebars"
    },
    {
      "language": "graphql"
    },
    {
      "language": "markdown"
    },
    {
      "language": "mdx"
    },
    {
      "language": "html"
    },
    {
      "language": "vue"
    },
    {
      "language": "yaml"
    },
    {
      "language": "ansible"
    },
    {
      "language": "home-assistant"
    },
    {
      "language": "jsonc",
      "scheme": "vscode-userdata"
    }
  ],
  "rangeLanguageSelector": [
    {
      "language": "javascript"
    },
    {
      "language": "javascriptreact"
    },
    {
      "language": "typescript"
    },
    {
      "language": "typescriptreact"
    },
    {
      "language": "json"
    },
    {
      "language": "graphql"
    }
  ]
}
["DEBUG" - 6:37:42 PM] Using bundled version of prettier.
["INFO" - 6:37:45 PM] Formatting file:///Volumes/Google%20Drive/Mi%20unidad/Asignaturas%20por%20an%CC%83o/Tercer%20an%CC%83o/Primer%20cuatrimestre/Modelado%20y%20Disen%CC%83o%20del%20Software/Modelado/ocl.md
["DEBUG" - 6:37:46 PM] Using bundled version of prettier.
["INFO" - 6:37:46 PM] Using ignore file (if present) at /Volumes/Google Drive/Mi unidad/Asignaturas por año/Tercer año/Primer cuatrimestre/Modelado y Diseño del Software/.prettierignore
["INFO" - 6:37:46 PM] File Info:
{
  "ignored": false,
  "inferredParser": "markdown"
}
["INFO" - 6:37:46 PM] No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration
["INFO" - 6:37:46 PM] Prettier Options:
{
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "always",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "filepath": "/Volumes/Google Drive/Mi unidad/Asignaturas por año/Tercer año/Primer cuatrimestre/Modelado y Diseño del Software/Modelado/ocl.md",
  "parser": "markdown"
}
["INFO" - 6:37:46 PM] Formatting completed in 0.123ms.
ntotten commented 2 years ago

This is an issue or feature request for the Prettier library itself rather than the VS Code extension for prettier. Please open an issue at https://github.com/prettier/prettier.

github-actions[bot] commented 2 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.