Skip to content

Preserve single-line html inside embedded html (tagged template) #749

@isAdrisal

Description

@isAdrisal

Based on denoland/deno#30677 (and also mentioned in denoland/deno#30103)

dprint-plugin-typescript version: 0.95.12

The current behaviour means that single-line, whitespace-sensitive html (like the below spans) are formatted with surrounding whitespace where there shouldn't be any.

I separately tested the behaviour in markup_fmt directly, which (correctly) treats <span> elements as whitespace-sensitive and doesn't add surrounding whitespace, and so confirmed the whitespace was being added by this plugin.

Input Code

let htmlStringOne = html`<span>foo</span>`;
let htmlStringTwo = html`  <span>foo</span>`;
let htmlStringThree = html`
<span>foo</span>`;

Expected Output

let htmlStringOne = html`<span>foo</span>`;
let htmlStringTwo = html`<span>foo</span>`;
let htmlStringThree = html`
    <span>foo</span>
`;

Actual Output

let htmlStringOne = html`
  <span>foo</span>
`;
let htmlStringTwo = html`
  <span>foo</span>
`;
let htmlStringThree = html`
  <span>foo</span>
`;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions