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

Parsing: Replace server serialization by parsed outerHTML #3545

Closed
wants to merge 1 commit into from

Conversation

aduth
Copy link
Member

@aduth aduth commented Nov 18, 2017

Related: #2806
Relies on: nylen/phpegjs#3 (changes manually effected here, but will be lost in future parser revisions)

This pull request seeks to change the behavior of selective wpautop application, simplifying the behavior to preserving the original markup of block content returned from the parser, rather than reserializing the parsed block node. In particular, this will be necessary for block nesting since, as implemented, the server is not capable of reserializing blocks with nested blocks if the block's save behavior is implemented on the client.

Testing instructions:

Ensure that tests pass:

npm test
phpunit

Repeat testing instructions from #2806

@aduth aduth added the [Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f label Nov 18, 2017
@aduth aduth requested review from dmsnell and mtias November 18, 2017 02:20
@dmsnell
Copy link
Member

dmsnell commented Nov 20, 2017

This is good work and I can clearly see places where it's going to be useful.

Do we think the most valuable about put is the block contents plus the block delimiters themselves though? What are the reasons for leaving those comment in vs. just returning everything inside the delimiters? (I know one is that it's easier in the parser to return the entire match than just the inside contents)

@aduth
Copy link
Member Author

aduth commented Nov 20, 2017

Do we think the most valuable about put is the block contents plus the block delimiters themselves though? What are the reasons for leaving those comment in vs. just returning everything inside the delimiters? (I know one is that it's easier in the parser to return the entire match than just the inside contents)

Yes, part of the objective here is that we want to preserve block content as-is without serializing anything. In the latter case, we would still need to serialize the comment attributes again. Another example is that validation becomes stricter (in a good way), verifying not only the contents within the delimiters, but the delimiters themselves (a few flagged issues fixed in these changes).

If we were to just return everything inside the delimiters, what then would be the main difference between innerHTML and outerHTML? Just that the latter would reflect the raw markup including that of its inner blocks?

@dmsnell
Copy link
Member

dmsnell commented Nov 20, 2017

If we were to just return everything inside the delimiters, what then would be the main difference between innerHTML and outerHTML? Just that the latter would reflect the raw markup including that of its inner blocks?

Actually I'm curious about how this accomplishes our goals in creating and operating over blocks, not specifically in how to test Gutenberg's code. If innerHTML isn't sufficient for things like autop, what is better about outerHTML vs being able to operate over the contents?

On that note, why isn't innerHTML sufficient for autop? Seems like that is even better because I'm guessing we don't want things like shortcodes messing up block boundaries. To me, it feels like passing the block structure into WordPress core is asking to break down the safe boundaries those blocks have until now preserved.

This is an entirely separate question though from whether it's right to prevent WordPress from serializing and reprinting the blocks. It seems obvious to me that by making the client-side JavaScript necessary to operate on the post content we've been inviting trouble, and that to me is a bigger culprit here.

@dmsnell
Copy link
Member

dmsnell commented Dec 11, 2017

@aduth what do you need to keep this moving? are there updates that affect its relevancy?

@aduth
Copy link
Member Author

aduth commented Dec 11, 2017

@dmsnell Yes, this may no longer be the direction I want to take here, and rather move wpautop handling to occur in the client when loading an existing post, which has a few advantages:

  • For all new or upgraded posts, autop can effectively be skipped, reducing server load for front-end display
  • The server does not need to know how to mimic block serialization behaviors, and this can be handled entirely in the client
  • This could tie into no-delimiter paragraph blocks (Text: handle legacy structures #589) if it's something we want to pursue
    • i.e. paragraph blocks get special treatment where comment delimiters are optional. Not sure how well this would pan out, but I know it's something @mtias has mentioned exploring.

@aduth
Copy link
Member Author

aduth commented Jan 4, 2018

Superseded by #4005

@aduth aduth closed this Jan 4, 2018
@aduth aduth deleted the add/parse-outer-html branch January 4, 2018 14:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Parsing Related to efforts to improving the parsing of a string of data and converting it into a different f
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants