Skip to content

Commit

Permalink
handle a couple of entity edge cases (tc39#489)
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot authored Oct 6, 2022
1 parent 34e14b8 commit 7bc7f2e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
4 changes: 3 additions & 1 deletion src/formatter/text.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ export function printText(text: string, indent: number): LineBuilder {
return entities[m];
}
const lower = m.toLowerCase();
if (lower === '≤' || lower === '&') {
if (lower === '<' || lower === '&') {
return lower;
} else if (lower === '&lt' || lower === '&amp') {
return lower + ';';
}
return m;
});
Expand Down
4 changes: 2 additions & 2 deletions test/formatter.js
Original file line number Diff line number Diff line change
Expand Up @@ -657,7 +657,7 @@ describe('entities', () => {
await assertDocFormatsAs(
`
<div>
some entities are transformed: &AMP; &frac12; &frac12 &fjlig; &CapitalDifferentialD;
some entities are transformed: &AMP; &AMP &LT &frac12; &frac12 &fjlig; &CapitalDifferentialD;
others are preserved: &amp; &lt; &nbsp; &nbsp &NotAnEntity;
</div>
<emu-alg>
Expand All @@ -666,7 +666,7 @@ describe('entities', () => {
`,
dedentKeepingTrailingNewline`
<div>
some entities are transformed: &amp; ½ ½ fj ⅅ
some entities are transformed: &amp; &amp; &lt; ½ ½ fj ⅅ
others are preserved: &amp; &lt; &nbsp; &nbsp &NotAnEntity;
</div>
<emu-alg>
Expand Down

0 comments on commit 7bc7f2e

Please sign in to comment.