diff --git a/CHANGELOG.unreleased.md b/CHANGELOG.unreleased.md index 6c7a41e7..2e52cba9 100644 --- a/CHANGELOG.unreleased.md +++ b/CHANGELOG.unreleased.md @@ -146,8 +146,31 @@ Previously, Prettier would sometimes ignore whitespace when formatting comments. ``` +### Handlebars: Improve comment formatting ([#6234] by [@gavinjoyce]) + +Previously, Prettier would incorrectly decode HTML entiites. + + +```hbs +// Input +

+ Some escaped characters: < > & +

+ +// Output (Prettier stable) +

+ Some escaped characters: < > & +

+ +// Output (Prettier master) +

+ Some escaped characters: < > & +

+``` + [#6209]: https://github.com/prettier/prettier/pull/6209 [#6186]: https://github.com/prettier/prettier/pull/6186 [#6186]: https://github.com/prettier/prettier/pull/6206 +[#6234]: https://github.com/prettier/prettier/pull/6234 [@duailibe]: https://github.com/duailibe [@gavinjoyce]: https://github.com/gavinjoyce diff --git a/package.json b/package.json index dcc40033..09c807eb 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,7 @@ "@angular/compiler": "7.2.9", "@babel/code-frame": "7.0.0", "@babel/parser": "7.2.0", - "@glimmer/syntax": "0.39.3", + "@glimmer/syntax": "0.41.0", "@iarna/toml": "2.2.3", "@typescript-eslint/typescript-estree": "1.10.2", "angular-estree-parser": "1.1.5", diff --git a/src/language-handlebars/parser-glimmer.js b/src/language-handlebars/parser-glimmer.js index a9b13b3b..3c4568b2 100644 --- a/src/language-handlebars/parser-glimmer.js +++ b/src/language-handlebars/parser-glimmer.js @@ -8,7 +8,8 @@ function parse(text) { return glimmer(text, { plugins: { ast: [] - } + }, + mode: "codemod" }); /* istanbul ignore next */ } catch (error) { diff --git a/tests/glimmer/__snapshots__/jsfmt.spec.js.snap b/tests/glimmer/__snapshots__/jsfmt.spec.js.snap index 0d8fe9aa..80f37894 100644 --- a/tests/glimmer/__snapshots__/jsfmt.spec.js.snap +++ b/tests/glimmer/__snapshots__/jsfmt.spec.js.snap @@ -1290,6 +1290,35 @@ singleQuote: true ================================================================================ `; +exports[`html-entities.hbs 1`] = ` +====================================options===================================== +parsers: ["glimmer"] +printWidth: 80 + | printWidth +=====================================input====================================== +

Some escaped characters: < > &

+=====================================output===================================== +

+ Some escaped characters: < > & +

+================================================================================ +`; + +exports[`html-entities.hbs 2`] = ` +====================================options===================================== +parsers: ["glimmer"] +printWidth: 80 +singleQuote: true + | printWidth +=====================================input====================================== +

Some escaped characters: < > &

+=====================================output===================================== +

+ Some escaped characters: < > & +

+================================================================================ +`; + exports[`literals.hbs 1`] = ` ====================================options===================================== parsers: ["glimmer"] diff --git a/tests/glimmer/html-entities.hbs b/tests/glimmer/html-entities.hbs new file mode 100644 index 00000000..0c767e88 --- /dev/null +++ b/tests/glimmer/html-entities.hbs @@ -0,0 +1 @@ +

Some escaped characters: < > &

\ No newline at end of file diff --git a/yarn.lock b/yarn.lock index da38e3a3..13bdf066 100644 --- a/yarn.lock +++ b/yarn.lock @@ -718,25 +718,25 @@ lodash "^4.17.11" to-fast-properties "^2.0.0" -"@glimmer/interfaces@^0.39.3": - version "0.39.3" - resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.39.3.tgz#1d46e1056c9ff3ce6174b82320893c027772e5f4" - integrity sha512-tmuZAUau8UbyGh4gLkpC6Vjdm0JP2dibAMMaU/yZG+SGSsQeT+bo+0XcEezscQDPihfXsBX4Z6yq98o15beYEA== +"@glimmer/interfaces@^0.41.0": + version "0.41.0" + resolved "https://registry.yarnpkg.com/@glimmer/interfaces/-/interfaces-0.41.0.tgz#3f571a181025406f29faed9006d0a914afb577b1" + integrity sha512-d0Ryj8iV3FiyMyT4QpwHNg2QFFEmdzI5cJFcbmC+OmuTe6eOQ52mLDlw1+D+a3ZDv8Jfj3l0QkEcEugCxDY+1Q== -"@glimmer/syntax@0.39.3": - version "0.39.3" - resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.39.3.tgz#a5220151b00c69fbd728e120dffc7f90fa5b4f24" - integrity sha512-Mb/d1hyWKZYANRPKoEGQ4wTc0kkcsjtxyN+J4ps2F1LQ5UKqJxDlgA/Tf9zXNHsd+A8dn25t5NIjQl7KIdsqOg== +"@glimmer/syntax@0.41.0": + version "0.41.0" + resolved "https://registry.yarnpkg.com/@glimmer/syntax/-/syntax-0.41.0.tgz#af033e48475e29a4784900c13695925d752f462d" + integrity sha512-sYmgUMdK0jX+3ZNX9C2TKvL1YZGsKIcXRicwnzoTC7F56z29CbSCc7o6Zf0CI4L2Q7FSnHDxldlSe48wBAr6vQ== dependencies: - "@glimmer/interfaces" "^0.39.3" - "@glimmer/util" "^0.39.3" + "@glimmer/interfaces" "^0.41.0" + "@glimmer/util" "^0.41.0" handlebars "^4.0.13" simple-html-tokenizer "^0.5.7" -"@glimmer/util@^0.39.3": - version "0.39.3" - resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.39.3.tgz#f6b0417c4b0a30f4ea693990f466e3d1eb442d37" - integrity sha512-2tzpxdgaQxMu9bHFqTpGDBYDtSWJWQZkBCFfkzCmPrJuCis3YK7m9hzYIaow7CsVLnO44Xmur+Bpq6IM9gVFXw== +"@glimmer/util@^0.41.0": + version "0.41.0" + resolved "https://registry.yarnpkg.com/@glimmer/util/-/util-0.41.0.tgz#743fa455d1d7fa0ce29688e932c231a99c0752cf" + integrity sha512-aKmQy62eRFhOZET9XmTB8MOA32G1FmD4d9HWL21OfdcGM4IbguRrWLMQc2DRh1YOE2AaT0PBrFrPmpNwFp5tpQ== "@iarna/toml@2.2.3": version "2.2.3"