Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why ignore em/strong/span? #7

Open
zxti opened this issue Oct 28, 2018 · 5 comments
Open

Why ignore em/strong/span? #7

zxti opened this issue Oct 28, 2018 · 5 comments

Comments

@zxti
Copy link

zxti commented Oct 28, 2018

I get ignoring something like pre, but was just curious why span tags are not beautified.

@Paul-Hebert
Copy link

👍 I'm curious about this as well. For my use case beautifying spans improves the readability of some code examples.

This is great overall though, thanks!

@jonschlinkert
Copy link
Owner

The main reason was that span and strong are both inline elements, and js-beautify seemed to produce unexpected results (often) when those elements weren't ignored.

I believe you can override the defaults by passing an unformatted array on the options.

@Paul-Hebert
Copy link

That makes sense. Thanks @jonschlinkert !

@rbottomley
Copy link

Please continue to ignore inline elements. Don't break my markup like Prettier does. Prettier will change:

text (<em>something here</em>) and stuff

to:

text (
  <em>something here</em>
) and stuff

which changes the rendered output from:

text (something here) and stuff

to:

text ( something here ) and stuff

Making the code more legible = good, altering the rendered output = bad.

@DanKaplanSES
Copy link

DanKaplanSES commented Sep 19, 2021

Please continue to ignore inline elements. Don't break my markup like Prettier does. Prettier will change:

It is possible for you to print it out the way you want, and for others to printed out the way they want.

I believe you can override the defaults by passing an unformatted array on the options.

Although you can do this, it doesn't seem to have any effect: strong and em are still on the same lines as their parents.

Relevant issue: beautifier/js-beautify#1900

Here is how you can achieve this:

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  return pretty($.html(), { unformatted: [], inline: [] } as any);

By the way, there are a lot of options that are undocumented and not in the types. Would it be possible to add what's missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants