prettier / prettier/prettier

Can't format vue expression with escaped html

Open
#14,696 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

lang:vue
Dominant language
JavaScript
Stars
52.3k
Forks
5k
Avg merge
19h 2m
Merged PRs (30d)
117

Description

Prettier pr-14506
Playground link

--parser vue
--trailing-comma es5

Input:

<template>
  <span>
    {{ a &lt; b 
    ? 1 
    : 2 }}
    {{ a &gt; b 
    ? 1 
    : 2 }}
  </span>
</template>
 
<script setup>
const a = 1, b = 2
</script>

Output:

<template>
  <span>
    {{ a &lt; b 
    ? 1 
    : 2 }}
    {{ a &gt; b 
    ? 1 
    : 2 }}
  </span>
</template>

<script setup>
const a = 1,
  b = 2;
</script>

Expected behavior:

Should unescape before parse.

Vue playground link

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Vue reproduction and the linked Vue playground, then trace how the formatter parses escaped HTML entities inside template expressions. Confirm the behavior with the provided input and output; done means expressions containing < and > are parsed and formatted correctly without changing the surrounding Vue template.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.