-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from wordpress-mobile/feature/parser
Use the GB parser pipeline
- Loading branch information
Showing
12 changed files
with
691 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/** @format */ | ||
|
||
module.exports = {}; |
Submodule gutenberg
updated
6 files
+3 −0 | blocks/api/index.native.js | |
+1 −1 | blocks/api/parser.js | |
+1,597 −0 | blocks/api/post-grammar-parser-pre-generated.js | |
+1 −0 | blocks/api/post-parser.js | |
+1 −0 | blocks/api/post-parser.native.js | |
+19 −0 | element/index.native.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
/** @format */ | ||
|
||
import './globals'; | ||
|
||
import renderer from 'react-test-renderer'; | ||
|
||
import App from './App'; | ||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** @format */ | ||
|
||
import { createElement } from '@gutenberg/element'; | ||
import jsdom from 'jsdom-jscore'; | ||
|
||
global.wp = { | ||
element: { | ||
createElement, // load the element creation function, needed by Gutenberg-web | ||
}, | ||
}; | ||
|
||
const doc = jsdom.html( '', null, null ); | ||
|
||
// inject a simple version of the missing createHTMLDocument method that `hpq` depends on | ||
doc.implementation.createHTMLDocument = function( html ) { | ||
return jsdom.html( html, null, null ); | ||
}; | ||
|
||
// `hpq` depends on `document` be available globally | ||
global.document = doc; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** @format */ | ||
|
||
import '../globals'; | ||
|
||
import { registerCoreBlocks } from '@gutenberg/core-blocks'; | ||
import { parse } from '@gutenberg/blocks'; | ||
|
||
registerCoreBlocks(); | ||
|
||
describe( 'Parser', () => { | ||
const codeContent = ` | ||
if name == "World": | ||
return "Hello World" | ||
else: | ||
return "Hello Pony"`; | ||
|
||
const originalCodeBlockHtml = `<pre><code>${ codeContent }</code></pre>`; | ||
|
||
const gbCodeBlockHtml = ` | ||
<!-- wp:code --> | ||
${ originalCodeBlockHtml } | ||
<!-- /wp:code -->`; | ||
|
||
it( 'parses the code block ok', () => { | ||
const codeBlockInstance = parse( gbCodeBlockHtml )[ 0 ]; | ||
expect( codeBlockInstance ).toBeTruthy(); | ||
} ); | ||
|
||
it( 'parses the code block content ok', () => { | ||
const codeBlockInstance = parse( gbCodeBlockHtml )[ 0 ]; | ||
|
||
expect( codeBlockInstance.isValid ).toEqual( true ); | ||
expect( codeBlockInstance.name ).toEqual( 'core/code' ); | ||
expect( codeBlockInstance.innerBlocks ).toHaveLength( 0 ); | ||
expect( codeBlockInstance.originalContent ).toEqual( originalCodeBlockHtml ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** @format */ | ||
|
||
import '../globals'; | ||
|
||
import { registerCoreBlocks } from '@gutenberg/core-blocks'; | ||
import { parse } from '@gutenberg/blocks'; | ||
|
||
registerCoreBlocks(); | ||
|
||
describe( 'Parser', () => { | ||
const originalMoreBlockHtml = '<!--more-->'; | ||
|
||
const gbMoreBlockHtml = ` | ||
<!-- wp:more --> | ||
${ originalMoreBlockHtml } | ||
<!-- /wp:more -->`; | ||
|
||
it( 'parses the more block ok', () => { | ||
const moreBlockInstance = parse( gbMoreBlockHtml )[ 0 ]; | ||
expect( moreBlockInstance ).toBeTruthy(); | ||
} ); | ||
|
||
it( 'parses the more block attributes ok', () => { | ||
const moreBlockInstance = parse( gbMoreBlockHtml )[ 0 ]; | ||
|
||
expect( moreBlockInstance.isValid ).toEqual( true ); | ||
expect( moreBlockInstance.name ).toEqual( 'core/more' ); | ||
expect( moreBlockInstance.innerBlocks ).toHaveLength( 0 ); | ||
expect( moreBlockInstance.originalContent ).toEqual( originalMoreBlockHtml ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.