-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Packages: Create new spec-parser
package
#7664
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,6 @@ build | |
build-module | ||
coverage | ||
node_modules | ||
packages/block-serialization-spec-parser | ||
test/e2e/test-plugins | ||
vendor |
This file was deleted.
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -203,6 +203,13 @@ function gutenberg_register_scripts_and_styles() { | |
filemtime( gutenberg_dir_path() . 'build/dom/index.js' ), | ||
true | ||
); | ||
wp_register_script( | ||
'wp-block-serialization-spec-parser', | ||
gutenberg_url( 'build/block-serialization-spec-parser/index.js' ), | ||
array(), | ||
filemtime( gutenberg_dir_path() . 'build/block-serialization-spec-parser/index.js' ), | ||
true | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we really need this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it fixes some issues, I remember seeing PR from @pento which added them everywhere. |
||
); | ||
wp_add_inline_script( | ||
'wp-dom', | ||
gutenberg_get_script_polyfill( array( | ||
|
@@ -290,7 +297,7 @@ function gutenberg_register_scripts_and_styles() { | |
wp_register_script( | ||
'wp-blocks', | ||
gutenberg_url( 'build/blocks/index.js' ), | ||
array( 'wp-blob', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-shortcode', 'wp-data', 'lodash' ), | ||
array( 'wp-blob', 'wp-deprecated', 'wp-dom', 'wp-element', 'wp-hooks', 'wp-i18n', 'wp-shortcode', 'wp-block-serialization-spec-parser', 'wp-data', 'lodash' ), | ||
filemtime( gutenberg_dir_path() . 'build/blocks/index.js' ), | ||
true | ||
); | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
package-lock=false |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# @wordpress/block-serialization-spec-parser | ||
|
||
This library contains the grammar file (`grammar.pegjs`) for WordPress posts which is a block serialization _specification_ which is used to generate the actual _parser_ which is also bundled in this package. | ||
|
||
PEG parser generators are available in many languages, though different libraries may require some translation of this grammar into their syntax. For more information see: | ||
* https://pegjs.org | ||
* https://en.wikipedia.org/wiki/Parsing_expression_grammar | ||
|
||
## Installation | ||
|
||
Install the module | ||
|
||
```bash | ||
npm install @wordpress/block-serialization-spec-parser --save | ||
``` | ||
|
||
## Usage | ||
|
||
```js | ||
import { parse } from '@wordpress/block-serialization-spec-parser'; | ||
|
||
parse( '<!-- wp:core/more --><!--more--><!-- /wp:core/more -->' ); | ||
// [{"attrs": null, "blockName": "core/more", "innerBlocks": [], "innerHTML": "<!--more-->"}] | ||
``` | ||
|
||
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p> |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we ignore the entire package? Could we just ignore the singular file(s) which are generated? The test file, for example, includes a number of legitimate code style violations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this should be only one file. Let me fix it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha, I know what happened. I used
toMatchInlineSnapshot
which uses prettier behind the scenes. We can't really use it with the current setup unless we adoptcalypso-prettier
:)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be addressed in #9166.