Skip to content

Commit

Permalink
Packages: Create new spec-parser package
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Jul 18, 2018
1 parent b06a335 commit ffc1961
Show file tree
Hide file tree
Showing 20 changed files with 1,690 additions and 1,661 deletions.
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

0 comments on commit ffc1961

Please sign in to comment.