Skip to content

Commit

Permalink
[Glimmer] preserve html entities
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinJoyce committed Jun 19, 2019
1 parent e8037ff commit b51d97d
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 18 deletions.
23 changes: 23 additions & 0 deletions CHANGELOG.unreleased.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,31 @@ Previously, Prettier would sometimes ignore whitespace when formatting comments.
</div>
```

### Handlebars: Improve comment formatting ([#6234] by [@gavinjoyce])

Previously, Prettier would incorrectly decode HTML entiites.

<!-- prettier-ignore -->
```hbs
// Input
<p>
Some escaped characters: &lt; &gt; &amp;
</p>
// Output (Prettier stable)
<p>
Some escaped characters: < > &
</p>
// Output (Prettier master)
<p>
Some escaped characters: &lt; &gt; &amp;
</p>
```

[#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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion src/language-handlebars/parser-glimmer.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ function parse(text) {
return glimmer(text, {
plugins: {
ast: []
}
},
mode: "codemod"
});
/* istanbul ignore next */
} catch (error) {
Expand Down
29 changes: 29 additions & 0 deletions tests/glimmer/__snapshots__/jsfmt.spec.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,35 @@ singleQuote: true
================================================================================
`;

exports[`html-entities.hbs 1`] = `
====================================options=====================================
parsers: ["glimmer"]
printWidth: 80
| printWidth
=====================================input======================================
<p>Some escaped characters: &lt; &gt; &amp;</p>
=====================================output=====================================
<p>
Some escaped characters: &lt; &gt; &amp;
</p>
================================================================================
`;

exports[`html-entities.hbs 2`] = `
====================================options=====================================
parsers: ["glimmer"]
printWidth: 80
singleQuote: true
| printWidth
=====================================input======================================
<p>Some escaped characters: &lt; &gt; &amp;</p>
=====================================output=====================================
<p>
Some escaped characters: &lt; &gt; &amp;
</p>
================================================================================
`;

exports[`literals.hbs 1`] = `
====================================options=====================================
parsers: ["glimmer"]
Expand Down
1 change: 1 addition & 0 deletions tests/glimmer/html-entities.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<p>Some escaped characters: &lt; &gt; &amp;</p>
32 changes: 16 additions & 16 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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/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==
dependencies:
"@glimmer/interfaces" "^0.39.3"
"@glimmer/util" "^0.39.3"
"@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.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.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"
Expand Down

0 comments on commit b51d97d

Please sign in to comment.