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

Block API: Indent serialized block output with tabs #6223

Merged
merged 1 commit into from
Apr 19, 2018

Conversation

aduth
Copy link
Member

@aduth aduth commented Apr 17, 2018

Related: #4456

This pull request seeks to propose indenting the serialized block output with tabs, rather than four spaces. Aside from being the objectively superior mode of indentation, tabs are advantageous for reducing the storage requirements of post content. As an example, for the demo post, using tabs saves 93 bytes. This number would be higher for content with significant indentation, notably heavily nested content.

I encountered this as part of implementing a custom serialize beautifier for #4456 (comment) , extracted here since there's a large number of affected fixture files and test assertions. The change itself is merely a single option to js-beautify: indent_with_tabs: true.

The block validator is intended to be whitespace-agnostic (aside from "meaningful" HTML whitespace), so there is intended to be no invalidations incurred by this change.

Testing instructions:

Ensure unit tests pass:

npm run test-unit

Verify that saving a post and reloading the editor results in no invalid blocks.

@aduth aduth added [Feature] Block API API that allows to express the block paradigm. Framework Issues related to broader framework topics, especially as it relates to javascript labels Apr 17, 2018
@noisysocks
Copy link
Member

Nice. This also fixes a bug where the HTML block complains about indentation using spaces after the editor reloads.

screen shot 2018-04-18 at 14 55 06

@aduth aduth added this to the 2.8 milestone Apr 18, 2018
@aduth aduth force-pushed the update/js-beautify-indent-tab branch from 0ae4979 to 0cb9915 Compare April 19, 2018 00:23
@aduth aduth merged commit 6950a81 into master Apr 19, 2018
@aduth aduth deleted the update/js-beautify-indent-tab branch April 19, 2018 00:58
nuzzio pushed a commit to nuzzio/gutenberg that referenced this pull request Apr 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block API API that allows to express the block paradigm. Framework Issues related to broader framework topics, especially as it relates to javascript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants