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

Packages: Create new spec-parser package #7664

Merged
merged 3 commits into from
Jul 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@ build
build-module
coverage
node_modules
packages/spec-parser
test/e2e/test-plugins
vendor
2 changes: 1 addition & 1 deletion bin/create-php-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const phpegjs = require( 'phpegjs' );
const fs = require( 'fs' );
const path = require( 'path' );

const peg = fs.readFileSync( 'blocks/api/post.pegjs', 'utf8' );
const peg = fs.readFileSync( 'packages/spec-parser/grammar.pegjs', 'utf8' );

const parser = pegjs.generate(
peg,
Expand Down
2 changes: 1 addition & 1 deletion bin/generate-public-grammar.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const parser = require( '../node_modules/pegjs/lib/parser.js' );
const fs = require( 'fs' );
const path = require( 'path' );
const grammarSource = fs.readFileSync( './blocks/api/post.pegjs', 'utf8' );
const grammarSource = fs.readFileSync( './packages/spec-parser/grammar.pegjs', 'utf8' );
const grammar = parser.parse( grammarSource );

function escape( text ) {
Expand Down
4 changes: 2 additions & 2 deletions blocks/api/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import { flow, castArray, mapValues, omit, stubFalse } from 'lodash';
import { autop } from '@wordpress/autop';
import { applyFilters } from '@wordpress/hooks';
import deprecated from '@wordpress/deprecated';
import { parse as grammarParse } from '@wordpress/spec-parser';

/**
* Internal dependencies
*/
import { parse as grammarParse } from './post-parser';
import { getBlockType, getUnknownTypeHandlerName } from './registration';
import { createBlock } from './factory';
import { isValidBlock } from './validation';
Expand Down Expand Up @@ -365,7 +365,7 @@ export function createBlockWithFallback( blockNode ) {
*
* @return {Function} An implementation which parses the post content.
*/
export const createParse = ( parseImplementation ) =>
const createParse = ( parseImplementation ) =>
( content ) => parseImplementation( content ).reduce( ( memo, blockNode ) => {
const block = createBlockWithFallback( blockNode );
if ( block ) {
Expand Down
Loading