prettier / prettier/plugin-xml

Feature Request: smart quote styles

Open
#937 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
278
Forks
46
Avg merge
1m
Merged PRs (30d)
13

Description

Could we have an option like "xmlQuoteAttributes": "least_escape" that auto-detects the best quote style for the attribute based on how many of each quotation character is found in the value?

That way we can use quotation marks in values and still have it be readable.

bracketSameLine

None

printWidth

120

singleAttributePerLine

false

tabWidth

2

xmlWhitespaceSensitivity

ignore

xmlSelfClosingSpace

true

Input XML
<div class='row'>
  <div class='col-1' />
  <div class='col-9 ps-4' t-field='o.partner_id.name' />
  <div class='col-2' t-out="f'{o.amount:.2f}'" />
</div>
Current output XML
<div class='row'>
  <div class='col-1' />
  <div class='col-9 ps-4' t-field='o.partner_id.name' />
  <div class='col-2' t-out='f&apos;{o.amount:.2f}&apos;' />
</div>
Expected Desired output XML
<div class='row'>
  <div class='col-1' />
  <div class='col-9 ps-4' t-field='o.partner_id.name' />
  <div class='col-2' t-out="f'{o.amount:.2f}'" />
</div>

Contributor guide

No contributing guide indexed for this repository

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

The issue names no files or tests. Start by tracing the XML attribute-formatting path and how formatter options are parsed, then determine how a least_escape choice should count quote characters in attribute values. Done means the option is supported and the supplied XML formats with the less-escaped quote style while existing options continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.