Skip to content

Use input_substr to retrieve text#3

Merged
nylen merged 1 commit intonylen:masterfrom
aduth:fix/text-input-substr
Nov 30, 2017
Merged

Use input_substr to retrieve text#3
nylen merged 1 commit intonylen:masterfrom
aduth:fix/text-input-substr

Conversation

@aduth
Copy link
Copy Markdown

@aduth aduth commented Nov 17, 2017

Related: Nordth@88960c4

The current implementation of $this->text() does not work correctly, since it attempts to apply substr on an array.

Warning: substr() expects parameter 1 to be string, array given in /srv/www/editor/htdocs/wp-content/plugins/gutenberg/lib/parser.php on line 105

The proposed changes here use $this->input_str instead to iterate the $this->input array. Further, it applies the fix from Nordth@88960c4 which otherwise does not correctly identify the termination of a token.

Fixtures have been updated to use the current Gutenberg post grammar as of WordPress/gutenberg#2743 (Edit: Correction: it includes a new outerHTML property which will be proposed soon, leveraging $this->text()). Fixtures for wp-gutenberg-post-with-errors have been removed since the new grammar is capable of identifying non-block content.

@aduth
Copy link
Copy Markdown
Author

aduth commented Nov 18, 2017

Related: WordPress/gutenberg#3545

@nylen
Copy link
Copy Markdown
Owner

nylen commented Nov 21, 2017

I agree with the code change itself (and this PR will fix #2), however:

Fixtures for wp-gutenberg-post-with-errors have been removed

With this change, there are no longer any tests for the Expected X or end of input case. I'd prefer to add the updated Gutenberg grammar in a new, separate set of fixture files that tests the desired functionality without removing existing tests.

Then, to fix the build, we'll need to update the PHP 5.2 versions of the test grammars.

I can help with any/all of this and release a new version when we're done, just let me know how you'd like to proceed.

@nylen
Copy link
Copy Markdown
Owner

nylen commented Nov 21, 2017

Rebasing after #5 may also help fix the build here.

@aduth
Copy link
Copy Markdown
Author

aduth commented Nov 27, 2017

I rebased and restored the original -with-errors fixtures to the previous grammar. I suppose I can see some value in just keeping them all, new grammar as an additional set. The current work to introduce the new grammar revisions (with outerHTML) is on pause. The bug here with text() should still be resolved, but not urgent for our needs for the moment.

@nylen
Copy link
Copy Markdown
Owner

nylen commented Nov 30, 2017

LGTM, thanks!

@nylen nylen merged commit 5a04bc0 into nylen:master Nov 30, 2017
@nylen nylen mentioned this pull request Nov 30, 2017
aduth added a commit to WordPress/gutenberg that referenced this pull request Nov 30, 2017
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Dec 14, 2017
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 5, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 9, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 10, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
@aduth aduth deleted the fix/text-input-substr branch January 16, 2018 21:21
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 20, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 27, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 30, 2018
A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806
aduth added a commit to WordPress/gutenberg that referenced this pull request Jan 30, 2018
* Framework: Drop server-side block serialization, wpautop

A parsed block has no awareness of where inner blocks exist in its innerHTML, so it cannot safely reserialize.

There are a few options:

- Since we merely skip wpautop for known blocks, we could avoid reserialization and return the block's original HTML verbatim if we had access to its outerHTML. See nylen/phpegjs#3

- Move wpautop behavior for freeform content to the editor client. This may align well with desires to transparently upgrade legacy paragraph content to paragraph blocks. This would also allow the server to avoid any preprocessing before showing a post on the front-end, assuming that the saved content has had wpautop applied already.

Acknowledging that this effectively reverts large parts of #2806

* Parser: Apply autop to fallback block content
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

Successfully merging this pull request may close these issues.

2 participants