js-beautify icon indicating copy to clipboard operation
js-beautify copied to clipboard

Feature Request: html option preserveNewTextLines

Open rasamassen opened this issue 5 years ago • 2 comments

Description

Referencing VSCode Issue 84386. VSCode uses js-beautify for formatting, and defaults wrap_line_length to 120.

Issue: Multiple runs of js-beautify on HTML with wrap_line_length set results in text with numerous unnecessary line breaks.

Solution: Because HTML (outside of the "pre" tag) doesn't render line breaks in plain text, either change the default to remove line breaks within plain text or add a setting called something like preserveNewTextLines that works like preserveNewLines but within a tag.

Environment

https://beautifier.io/ Beautify HTML

Input

<p>See Spot. This is a perfectly normal and simple English sentence used to show how the language can expand over time.</p>

Output

This looks fine.

<p>See Spot. This is a perfectly normal and simple English sentence used to show how the language can expand over time.
</p>

Modified Input

Add "very far" to the simple sentence.

<p>See Spot very far. This is a perfectly normal and simple English sentence used to show how the language can expand over time.
</p>

Output

I mean, why does the "p" have its own line? But otherwise fine.

<p>See Spot very far. This is a perfectly normal and simple English sentence used to show how the language can expand
    over time.
</p>

Modified Input

Oops! Forgot the verb. Add "run".

<p>See Spot run very far. This is a perfectly normal and simple English sentence used to show how the language can expand
    over time.
</p>

Output

Multiple this by millions and suddenly my code looks atrocious! (Seriously)

<p>See Spot run very far. This is a perfectly normal and simple English sentence used to show how the language can
    expand
    over time.
</p>

Expected Output

I'd like to see this output:

<p>See Spot run very far. This is a perfectly normal and simple English sentence used to show how the language can
    expand over time.</p>

rasamassen avatar Nov 11 '19 17:11 rasamassen

@rasamassen This sounds reasonable.

bitwiseman avatar Nov 14 '19 00:11 bitwiseman

Posting here just hoping someone will tackle this feature request.

rasamassen avatar Sep 08 '22 13:09 rasamassen