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

Edit as HTML should indent my code #12397

Closed
v18 opened this issue Nov 28, 2018 · 6 comments
Closed

Edit as HTML should indent my code #12397

v18 opened this issue Nov 28, 2018 · 6 comments
Labels
[Type] Enhancement A suggestion for improvement.

Comments

@v18
Copy link

v18 commented Nov 28, 2018

When I click on 'Edit as HTML' when on a Gutenberg list block, I see this:

<ol><li>Apples</li><li>Oranges</li><li>Limes</li><li>Lemons</li></ol>

It's be better if the HTML was neatly spaced + indented, like so:

<ol>
  <li>Apples</li>
  <li>Oranges</li>
  <li>Limes</li>
  <li>Lemons</li>
</ol>

Some images to compare:

Gutenberg visual:

classic-list-html

gutenberg-list-html

gutenberg-list-visual

@designsimply designsimply added [Type] Enhancement A suggestion for improvement. [Type] Code Quality Issues or PRs that relate to code quality [Block] List Affects the List Block labels Nov 28, 2018
@ellatrix ellatrix removed [Type] Code Quality Issues or PRs that relate to code quality [Block] List Affects the List Block labels Nov 29, 2018
@ellatrix
Copy link
Member

The HTML "beautifier" was intentionally removed. Cc @aduth
Note that this is a general issue for all blocks, not just lists.

@aduth
Copy link
Member

aduth commented Nov 29, 2018

Previously: #7892

It should be noted that there could be different behaviors between what's presented for editing in "Edit as HTML" and what's actually saved as markup of the post.

@ali1234
Copy link

ali1234 commented Dec 12, 2018

That bug seems to indicate that the editor is supposed to preserve whitespace? Because for me it does not. It always runs everything into a single line.

@mtias
Copy link
Member

mtias commented Aug 30, 2020

Going to close this. Once better async load is present there's a willingness to add some more syntax highlighting to HTML editing.

@mtias mtias closed this as completed Aug 30, 2020
@mikegwhit
Copy link

mikegwhit commented Apr 14, 2021

Bump, this is what I came here for.. it's pretty unthinkable that this hasn't been addressed? Can I help submit a PR or similar? Has anything been drafted for how to address this technically? It sounds like there must be a hook when switching the edit mode to HTML at which point HTML can be beautified if it hasn't. Then thereafter HTML can be preserved as developer left it, or minified if developer makes no edits to HTML. It sounds like technically it may be hard to preserve an "edit version" of a post vs. a minified "publish version" of a post, however.

I had to go to a third-party website to beautify my table's HTML which was wild. I am just getting back into WordPress after some years of hiatus.

I cannot imagine in the scheme of things whitespace in blocks that users edit is going to have a giant hit on performance when compared to the UX tradeoff currently experienced.

CC @mtias

@mtias
Copy link
Member

mtias commented Jun 25, 2021

There are a few mixed things here: how code is stored and how code is presented. For code presentation the best solution was using a proper editor that handled lines and some level code highlight. For saving code the decision was not to touch the source as per #7892. It's certainly possible to beautify on render and not commit unless there are changes. If someone wants to explore that we can look into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

No branches or pull requests

7 participants