Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not formatting my xml, don't see a trace of the plugin being used/loaded in the prettier output #160

Closed
piejanssens opened this issue Feb 3, 2021 · 4 comments

Comments

@piejanssens
Copy link

piejanssens commented Feb 3, 2021

Using VS Code in WSL mode, prettier and @prettier/plugin-xml installed globally.

The only formatting effect that I see is in my test.xml the space added in the declaration changing it from <?xml version="1.0"?> to <?xml version="1.0" ?>.

<?xml version="1.0" ?>
<contact-info>
                <name>Tanmay Patil</name><company>TutorialsPoint</company>
   <phone>(011) 123-4567</phone>
</contact-info>
["INFO" - 10:04:46 AM] Formatting /mnt/c/Users/pietejanssens/code/career-insights/test.xml
["INFO" - 10:04:46 AM] Using ignore file (if present) at /mnt/c/Users/pietejanssens/code/.prettierignore
["INFO" - 10:04:46 AM] Loaded module 'prettier@2.2.1' from '/home/pieter/.nvm/versions/node/v14.15.4/lib/node_modules/prettier'
["INFO" - 10:04:46 AM] File Info:
{
  "ignored": false,
  "inferredParser": "xml"
}
["INFO" - 10:04:46 AM] No local configuration (i.e. .prettierrc or .editorconfig) detected, falling back to VS Code configuration
["INFO" - 10:04:46 AM] Prettier Options:
{
  "arrowParens": "always",
  "bracketSpacing": true,
  "endOfLine": "lf",
  "htmlWhitespaceSensitivity": "css",
  "insertPragma": false,
  "jsxBracketSameLine": false,
  "jsxSingleQuote": false,
  "printWidth": 80,
  "proseWrap": "preserve",
  "quoteProps": "as-needed",
  "requirePragma": false,
  "semi": true,
  "singleQuote": false,
  "tabWidth": 2,
  "trailingComma": "es5",
  "useTabs": false,
  "vueIndentScriptAndStyle": false,
  "filepath": "/mnt/c/Users/pietejanssens/code/test.xml",
  "parser": "xml"
}
["INFO" - 10:04:46 AM] Formatting completed in 111.7021ms.
@kddnewton
Copy link
Member

By default every tag in XML is whitespace-sensitive, so this is acting as designed. If you want to ignore whitespace sensitivity, you should use the option listed in the README, and set xmlWhitespaceSensitivity to "ignore".

@piejanssens
Copy link
Author

Thanks, I did read the README, but didn't see or think that the xmlWhitespaceSensitivity would have that effect.
Adding "prettier.xmlWhitespaceSensitivity": "ignore" to vscode settings.json does not get passed to prettier or the plugin.
Adding it to a .prettierrc file does get taken into consideration, but I don't see the formatting happening.

@kddnewton
Copy link
Member

Can you run it again with the debug and put the output here?

@piejanssens
Copy link
Author

Today it works. Strange, but I'll take it. I'll file an issue with the vs code plugin as it would be really great if a global default config could be set via settings.json.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants