Documentation does not clarify how --embedded-language-formatting
works
#15771
tannerstern
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello all!
My team just adopted Prettier and I am so pleased with it! It will be such a good thing to have style
nit
comments be a thing of the past.However, I wanted to note that I spent about an hour just now trying to figure out an issue that I think should be documented. Our platform is built with Lit (and its predecessor Polymer), so we rely heavily on embedded language formatting; most of our files are JavaScript files with
html`<div> ... </div>`
templates inside of them. Curiously, some of our files had these embedded HTML blocks properly formatted, while others were not formatted at all.After scouring the docs (without success), I added the
prettier.enableDebugLogs
to my VS Codesettings.js
and started pulling my half-formatted file apart. Initially, the debug logs reported no errors. Eventually I tried copying all of the HTML into a new file with HTML as the selected language mode, and only then did Prettier report that there was an unclosed HTML tag (a markup error) that was preventing the whole block from being formatted. After correcting this error, voila! Prettier was able to format the embedded code no problem.I understand that Prettier formatting embedded code at all is a luxury, but I do think it would be worth clarifying this behavior somewhere (perhaps in the option description?); that if a syntax error is encountered, Prettier will not format the embedded code.
Beta Was this translation helpful? Give feedback.
All reactions