diff --git a/blocks/api/post.pegjs b/blocks/api/post.pegjs index 15635d4f1aa76..576970d10c3d2 100644 --- a/blocks/api/post.pegjs +++ b/blocks/api/post.pegjs @@ -169,33 +169,9 @@ Block_List } Token - = Tag_More - / Block_Void + = Block_Void / Block_Balanced -Tag_More - = "") .)+) { /** **/ return text })? WS* "-->" noTeaser:(WS* "")? - { /** (bool) $noTeaser ); - if ( ! empty( $customText ) ) { - $attrs['customText'] = $customText; - } - return array( - 'blockName' => 'core/more', - 'attrs' => $attrs, - 'innerHTML' => '' - ); - ?> **/ - return { - blockName: 'core/more', - attrs: { - customText: customText || undefined, - noTeaser: !! noTeaser - }, - innerHTML: '' - } - } - Block_Void = " comment is found, we need to look for any + // sibling, but it may not be a direct sibling + // (whitespace typically lies in between) + let sibling = node; + let noTeaser = false; + while ( ( sibling = sibling.nextSibling ) ) { + if ( + sibling.nodeType === COMMENT_NODE && + sibling.nodeValue === 'noteaser' + ) { + noTeaser = true; + sibling.parentNode.removeChild( sibling ); + break; + } + } + + // Conjure up a custom More element + const more = createMore( customText, noTeaser ); + + // Find the first ancestor to which the More element can be appended; + // appending to the closer P parents fails + let parent = node.parentNode; + while ( parent.nodeName.toLowerCase() === 'p' && parent.parentNode ) { + parent = parent.parentNode; + } + parent.appendChild( more ); + } + node.parentNode.removeChild( node ); } + +function createMore( customText, noTeaser ) { + const node = document.createElement( 'wp-block' ); + node.dataset.block = 'core/more'; + if ( customText ) { + node.dataset.customText = customText; + } + if ( noTeaser ) { + // "Boolean" data attribute + node.dataset.noTeaser = ''; + } + return node; +} diff --git a/blocks/api/serializer.js b/blocks/api/serializer.js index d98132fe20eec..268eaebaf5b2f 100644 --- a/blocks/api/serializer.js +++ b/blocks/api/serializer.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { isEmpty, reduce, isObject, castArray, compact, startsWith } from 'lodash'; +import { isEmpty, reduce, isObject, castArray, startsWith } from 'lodash'; import { html as beautifyHtml } from 'js-beautify'; import isEqualShallow from 'is-equal-shallow'; @@ -239,19 +239,6 @@ export function serializeBlock( block ) { const saveAttributes = getCommentAttributes( block.attributes, blockType ); switch ( blockName ) { - case 'core/more': - const { customText, noTeaser } = saveAttributes; - - const moreTag = customText ? - `` : - ''; - - const noTeaserTag = noTeaser ? - '' : - ''; - - return compact( [ moreTag, noTeaserTag ] ).join( '\n' ); - case getUnknownTypeHandlerName(): return saveContent; diff --git a/blocks/api/test/serializer.js b/blocks/api/test/serializer.js index ec2bfde75c36f..439787aef1ac4 100644 --- a/blocks/api/test/serializer.js +++ b/blocks/api/test/serializer.js @@ -24,6 +24,7 @@ import { } from '../registration'; import { createBlock } from '../'; import InnerBlocks from '../../inner-blocks'; +import { settings as moreSettings } from '../../library/more'; describe( 'block serializer', () => { beforeAll( () => { @@ -285,29 +286,18 @@ describe( 'block serializer', () => { describe( 'serializeBlock()', () => { describe( '"more" block', () => { beforeEach( () => { - registerBlockType( 'core/more', { - category: 'layout', - title: 'more', - attributes: { - customText: { - type: 'string', - }, - noTeaser: { - type: 'boolean', - default: false, - }, - }, - - save: () => null, - } ); + registerBlockType( 'core/more', moreSettings ); } ); + // FIXME: These tests aren't relevant anymore, but I kept them in + // the diff to better illustrate the changes. + it( 'serializes without text', () => { const block = createBlock( 'core/more', {} ); const content = serializeBlock( block ); - expect( content ).toBe( '' ); + expect( content ).toBe( '\n\n' ); } ); it( 'serializes with text', () => { @@ -317,7 +307,7 @@ describe( 'block serializer', () => { const content = serializeBlock( block ); - expect( content ).toBe( '' ); + expect( content ).toBe( '\n\n' ); } ); it( 'serializes with no teaser', () => { @@ -327,7 +317,7 @@ describe( 'block serializer', () => { const content = serializeBlock( block ); - expect( content ).toBe( '\n' ); + expect( content ).toBe( '\n\n\n' ); } ); } ); diff --git a/blocks/library/more/index.js b/blocks/library/more/index.js index 1e63af6ab6b6c..6821e4ed0eb24 100644 --- a/blocks/library/more/index.js +++ b/blocks/library/more/index.js @@ -1,13 +1,20 @@ +/** + * External dependencies + */ +import { compact } from 'lodash'; + /** * WordPress dependencies */ import { __ } from '@wordpress/i18n'; import { ToggleControl } from '@wordpress/components'; +import { RawHTML } from '@wordpress/element'; /** * Internal dependencies */ import './editor.scss'; +import { createBlock } from '../../api'; import InspectorControls from '../../inspector-controls'; export const name = 'core/more'; @@ -39,6 +46,28 @@ export const settings = { }, }, + transforms: { + from: [ + { + type: 'raw', + isMatch: ( node ) => node.dataset.block === 'core/more', + transform( node ) { + const { customText, noTeaser } = node.dataset; + const attrs = {}; + // Don't copy unless defined and not an empty string + if ( customText ) { + attrs.customText = customText; + } + // Special handling for boolean + if ( noTeaser === '' ) { + attrs.noTeaser = true; + } + return createBlock( 'core/more', attrs ); + }, + }, + ], + }, + edit( { attributes, setAttributes, isSelected } ) { const { customText, noTeaser } = attributes; @@ -68,7 +97,21 @@ export const settings = { ]; }, - save() { - return null; + save( { attributes } ) { + const { customText, noTeaser } = attributes; + + const moreTag = customText ? + `` : + ''; + + const noTeaserTag = noTeaser ? + '' : + ''; + + return ( + + { compact( [ moreTag, noTeaserTag ] ).join( '\n' ) } + + ); }, }; diff --git a/blocks/test/fixtures/core__more.html b/blocks/test/fixtures/core__more.html index 61f3b597d7a7f..b3b4f9e5e4926 100644 --- a/blocks/test/fixtures/core__more.html +++ b/blocks/test/fixtures/core__more.html @@ -1 +1,3 @@ + + diff --git a/blocks/test/fixtures/core__more.json b/blocks/test/fixtures/core__more.json index 4ba7ca6254470..ea7b6d9b6528d 100644 --- a/blocks/test/fixtures/core__more.json +++ b/blocks/test/fixtures/core__more.json @@ -7,6 +7,6 @@ "noTeaser": false }, "innerBlocks": [], - "originalContent": "" + "originalContent": "" } ] diff --git a/blocks/test/fixtures/core__more.parsed.json b/blocks/test/fixtures/core__more.parsed.json index d3e17034f0dc7..cdf33d5851657 100644 --- a/blocks/test/fixtures/core__more.parsed.json +++ b/blocks/test/fixtures/core__more.parsed.json @@ -1,10 +1,9 @@ [ { "blockName": "core/more", - "attrs": { - "noTeaser": false - }, - "innerHTML": "" + "attrs": null, + "innerBlocks": [], + "innerHTML": "\n\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__more.serialized.html b/blocks/test/fixtures/core__more.serialized.html index 61f3b597d7a7f..3b02c97e91b67 100644 --- a/blocks/test/fixtures/core__more.serialized.html +++ b/blocks/test/fixtures/core__more.serialized.html @@ -1 +1,3 @@ + + diff --git a/blocks/test/fixtures/core__more__custom-text-teaser.html b/blocks/test/fixtures/core__more__custom-text-teaser.html index 6f44e29e7e53b..1dcca9096610a 100644 --- a/blocks/test/fixtures/core__more__custom-text-teaser.html +++ b/blocks/test/fixtures/core__more__custom-text-teaser.html @@ -1,2 +1,4 @@ + + diff --git a/blocks/test/fixtures/core__more__custom-text-teaser.json b/blocks/test/fixtures/core__more__custom-text-teaser.json index c37da83a834bd..41dfb4b410a3c 100644 --- a/blocks/test/fixtures/core__more__custom-text-teaser.json +++ b/blocks/test/fixtures/core__more__custom-text-teaser.json @@ -8,6 +8,6 @@ "noTeaser": true }, "innerBlocks": [], - "originalContent": "" + "originalContent": "\n" } ] diff --git a/blocks/test/fixtures/core__more__custom-text-teaser.parsed.json b/blocks/test/fixtures/core__more__custom-text-teaser.parsed.json index 48d92cf95e077..6bf85564708c2 100644 --- a/blocks/test/fixtures/core__more__custom-text-teaser.parsed.json +++ b/blocks/test/fixtures/core__more__custom-text-teaser.parsed.json @@ -5,7 +5,8 @@ "customText": "Continue Reading", "noTeaser": true }, - "innerHTML": "" + "innerBlocks": [], + "innerHTML": "\n\n\n" }, { "attrs": {}, diff --git a/blocks/test/fixtures/core__more__custom-text-teaser.serialized.html b/blocks/test/fixtures/core__more__custom-text-teaser.serialized.html index 6f44e29e7e53b..6cc18dcfba306 100644 --- a/blocks/test/fixtures/core__more__custom-text-teaser.serialized.html +++ b/blocks/test/fixtures/core__more__custom-text-teaser.serialized.html @@ -1,2 +1,4 @@ + + diff --git a/lib/parser.php b/lib/parser.php index bfcd03c2d806b..f69f53396ba82 100644 --- a/lib/parser.php +++ b/lib/parser.php @@ -256,27 +256,11 @@ private function peg_buildException($message, $expected, $pos) { private $peg_c25; private $peg_c26; private $peg_c27; - private $peg_c28; - private $peg_c29; - private $peg_c30; - private $peg_c31; private function peg_f0($pre, $t, $html) { return array( $t, $html ); } private function peg_f1($pre, $ts, $post) { return peg_join_blocks( $pre, $ts, $post ); } - private function peg_f2($text) { return $text; } - private function peg_f3($customText, $noTeaser) { - $attrs = array( 'noTeaser' => (bool) $noTeaser ); - if ( ! empty( $customText ) ) { - $attrs['customText'] = $customText; - } - return array( - 'blockName' => 'core/more', - 'attrs' => $attrs, - 'innerHTML' => '' - ); - } - private function peg_f4($blockName, $a) { return $a; } - private function peg_f5($blockName, $attrs) { + private function peg_f2($blockName, $a) { return $a; } + private function peg_f3($blockName, $attrs) { return array( 'blockName' => $blockName, 'attrs' => $attrs, @@ -284,7 +268,7 @@ private function peg_f5($blockName, $attrs) { 'innerHTML' => '', ); } - private function peg_f6($s, $children, $e) { + private function peg_f4($s, $children, $e) { list( $innerHTML, $innerBlocks ) = peg_array_partition( $children, 'is_string' ); return array( @@ -294,19 +278,19 @@ private function peg_f6($s, $children, $e) { 'innerHTML' => implode( '', $innerHTML ), ); } - private function peg_f7($blockName, $attrs) { + private function peg_f5($blockName, $attrs) { return array( 'blockName' => $blockName, 'attrs' => $attrs, ); } - private function peg_f8($blockName) { + private function peg_f6($blockName) { return array( 'blockName' => $blockName, ); } - private function peg_f9($type) { return "core/$type"; } - private function peg_f10($attrs) { return json_decode( $attrs, true ); } + private function peg_f7($type) { return "core/$type"; } + private function peg_f8($attrs) { return json_decode( $attrs, true ); } private function peg_parseBlock_List() { @@ -619,286 +603,9 @@ private function peg_parseBlock_List() { private function peg_parseToken() { - $s0 = $this->peg_parseTag_More(); + $s0 = $this->peg_parseBlock_Void(); if ($s0 === $this->peg_FAILED) { - $s0 = $this->peg_parseBlock_Void(); - if ($s0 === $this->peg_FAILED) { - $s0 = $this->peg_parseBlock_Balanced(); - } - } - - return $s0; - } - - private function peg_parseTag_More() { - - $s0 = $this->peg_currPos; - if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c1) { - $s1 = $this->peg_c1; - $this->peg_currPos += 4; - } else { - $s1 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c2); - } - } - if ($s1 !== $this->peg_FAILED) { - $s2 = array(); - $s3 = $this->peg_parseWS(); - while ($s3 !== $this->peg_FAILED) { - $s2[] = $s3; - $s3 = $this->peg_parseWS(); - } - if ($s2 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c3) { - $s3 = $this->peg_c3; - $this->peg_currPos += 4; - } else { - $s3 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c4); - } - } - if ($s3 !== $this->peg_FAILED) { - $s4 = $this->peg_currPos; - $s5 = array(); - $s6 = $this->peg_parseWS(); - if ($s6 !== $this->peg_FAILED) { - while ($s6 !== $this->peg_FAILED) { - $s5[] = $s6; - $s6 = $this->peg_parseWS(); - } - } else { - $s5 = $this->peg_FAILED; - } - if ($s5 !== $this->peg_FAILED) { - $s6 = $this->peg_currPos; - $s7 = array(); - $s8 = $this->peg_currPos; - $s9 = $this->peg_currPos; - $this->peg_silentFails++; - $s10 = $this->peg_currPos; - $s11 = array(); - $s12 = $this->peg_parseWS(); - while ($s12 !== $this->peg_FAILED) { - $s11[] = $s12; - $s12 = $this->peg_parseWS(); - } - if ($s11 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s12 = $this->peg_c5; - $this->peg_currPos += 3; - } else { - $s12 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); - } - } - if ($s12 !== $this->peg_FAILED) { - $s11 = array($s11, $s12); - $s10 = $s11; - } else { - $this->peg_currPos = $s10; - $s10 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s10; - $s10 = $this->peg_FAILED; - } - $this->peg_silentFails--; - if ($s10 === $this->peg_FAILED) { - $s9 = null; - } else { - $this->peg_currPos = $s9; - $s9 = $this->peg_FAILED; - } - if ($s9 !== $this->peg_FAILED) { - if ($this->input_length > $this->peg_currPos) { - $s10 = $this->input_substr($this->peg_currPos, 1); - $this->peg_currPos++; - } else { - $s10 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c0); - } - } - if ($s10 !== $this->peg_FAILED) { - $s9 = array($s9, $s10); - $s8 = $s9; - } else { - $this->peg_currPos = $s8; - $s8 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s8; - $s8 = $this->peg_FAILED; - } - if ($s8 !== $this->peg_FAILED) { - while ($s8 !== $this->peg_FAILED) { - $s7[] = $s8; - $s8 = $this->peg_currPos; - $s9 = $this->peg_currPos; - $this->peg_silentFails++; - $s10 = $this->peg_currPos; - $s11 = array(); - $s12 = $this->peg_parseWS(); - while ($s12 !== $this->peg_FAILED) { - $s11[] = $s12; - $s12 = $this->peg_parseWS(); - } - if ($s11 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s12 = $this->peg_c5; - $this->peg_currPos += 3; - } else { - $s12 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); - } - } - if ($s12 !== $this->peg_FAILED) { - $s11 = array($s11, $s12); - $s10 = $s11; - } else { - $this->peg_currPos = $s10; - $s10 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s10; - $s10 = $this->peg_FAILED; - } - $this->peg_silentFails--; - if ($s10 === $this->peg_FAILED) { - $s9 = null; - } else { - $this->peg_currPos = $s9; - $s9 = $this->peg_FAILED; - } - if ($s9 !== $this->peg_FAILED) { - if ($this->input_length > $this->peg_currPos) { - $s10 = $this->input_substr($this->peg_currPos, 1); - $this->peg_currPos++; - } else { - $s10 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c0); - } - } - if ($s10 !== $this->peg_FAILED) { - $s9 = array($s9, $s10); - $s8 = $s9; - } else { - $this->peg_currPos = $s8; - $s8 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s8; - $s8 = $this->peg_FAILED; - } - } - } else { - $s7 = $this->peg_FAILED; - } - if ($s7 !== $this->peg_FAILED) { - $s6 = $this->input_substr($s6, $this->peg_currPos - $s6); - } else { - $s6 = $s7; - } - if ($s6 !== $this->peg_FAILED) { - $this->peg_reportedPos = $s4; - $s5 = $this->peg_f2($s6); - $s4 = $s5; - } else { - $this->peg_currPos = $s4; - $s4 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s4; - $s4 = $this->peg_FAILED; - } - if ($s4 === $this->peg_FAILED) { - $s4 = null; - } - if ($s4 !== $this->peg_FAILED) { - $s5 = array(); - $s6 = $this->peg_parseWS(); - while ($s6 !== $this->peg_FAILED) { - $s5[] = $s6; - $s6 = $this->peg_parseWS(); - } - if ($s5 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s6 = $this->peg_c5; - $this->peg_currPos += 3; - } else { - $s6 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); - } - } - if ($s6 !== $this->peg_FAILED) { - $s7 = $this->peg_currPos; - $s8 = array(); - $s9 = $this->peg_parseWS(); - while ($s9 !== $this->peg_FAILED) { - $s8[] = $s9; - $s9 = $this->peg_parseWS(); - } - if ($s8 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 15) === $this->peg_c7) { - $s9 = $this->peg_c7; - $this->peg_currPos += 15; - } else { - $s9 = $this->peg_FAILED; - if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c8); - } - } - if ($s9 !== $this->peg_FAILED) { - $s8 = array($s8, $s9); - $s7 = $s8; - } else { - $this->peg_currPos = $s7; - $s7 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s7; - $s7 = $this->peg_FAILED; - } - if ($s7 === $this->peg_FAILED) { - $s7 = null; - } - if ($s7 !== $this->peg_FAILED) { - $this->peg_reportedPos = $s0; - $s1 = $this->peg_f3($s4, $s7); - $s0 = $s1; - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; - } - } else { - $this->peg_currPos = $s0; - $s0 = $this->peg_FAILED; + $s0 = $this->peg_parseBlock_Balanced(); } return $s0; @@ -928,13 +635,13 @@ private function peg_parseBlock_Void() { $s2 = $this->peg_FAILED; } if ($s2 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c9) { - $s3 = $this->peg_c9; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c3) { + $s3 = $this->peg_c3; $this->peg_currPos += 3; } else { $s3 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c10); + $this->peg_fail($this->peg_c4); } } if ($s3 !== $this->peg_FAILED) { @@ -966,7 +673,7 @@ private function peg_parseBlock_Void() { } if ($s8 !== $this->peg_FAILED) { $this->peg_reportedPos = $s6; - $s7 = $this->peg_f4($s4, $s7); + $s7 = $this->peg_f2($s4, $s7); $s6 = $s7; } else { $this->peg_currPos = $s6; @@ -980,18 +687,18 @@ private function peg_parseBlock_Void() { $s6 = null; } if ($s6 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c11) { - $s7 = $this->peg_c11; + if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c5) { + $s7 = $this->peg_c5; $this->peg_currPos += 4; } else { $s7 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c12); + $this->peg_fail($this->peg_c6); } } if ($s7 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f5($s4, $s6); + $s1 = $this->peg_f3($s4, $s6); $s0 = $s1; } else { $this->peg_currPos = $s0; @@ -1120,7 +827,7 @@ private function peg_parseBlock_Balanced() { $s3 = $this->peg_parseBlock_End(); if ($s3 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f6($s1, $s2, $s3); + $s1 = $this->peg_f4($s1, $s2, $s3); $s0 = $s1; } else { $this->peg_currPos = $s0; @@ -1162,13 +869,13 @@ private function peg_parseBlock_Start() { $s2 = $this->peg_FAILED; } if ($s2 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c9) { - $s3 = $this->peg_c9; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c3) { + $s3 = $this->peg_c3; $this->peg_currPos += 3; } else { $s3 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c10); + $this->peg_fail($this->peg_c4); } } if ($s3 !== $this->peg_FAILED) { @@ -1200,7 +907,7 @@ private function peg_parseBlock_Start() { } if ($s8 !== $this->peg_FAILED) { $this->peg_reportedPos = $s6; - $s7 = $this->peg_f4($s4, $s7); + $s7 = $this->peg_f2($s4, $s7); $s6 = $s7; } else { $this->peg_currPos = $s6; @@ -1214,18 +921,18 @@ private function peg_parseBlock_Start() { $s6 = null; } if ($s6 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s7 = $this->peg_c5; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) { + $s7 = $this->peg_c7; $this->peg_currPos += 3; } else { $s7 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); + $this->peg_fail($this->peg_c8); } } if ($s7 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f7($s4, $s6); + $s1 = $this->peg_f5($s4, $s6); $s0 = $s1; } else { $this->peg_currPos = $s0; @@ -1283,13 +990,13 @@ private function peg_parseBlock_End() { $s2 = $this->peg_FAILED; } if ($s2 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c13) { - $s3 = $this->peg_c13; + if ($this->input_substr($this->peg_currPos, 4) === $this->peg_c9) { + $s3 = $this->peg_c9; $this->peg_currPos += 4; } else { $s3 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c14); + $this->peg_fail($this->peg_c10); } } if ($s3 !== $this->peg_FAILED) { @@ -1306,18 +1013,18 @@ private function peg_parseBlock_End() { $s5 = $this->peg_FAILED; } if ($s5 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s6 = $this->peg_c5; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) { + $s6 = $this->peg_c7; $this->peg_currPos += 3; } else { $s6 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); + $this->peg_fail($this->peg_c8); } } if ($s6 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f8($s4); + $s1 = $this->peg_f6($s4); $s0 = $s1; } else { $this->peg_currPos = $s0; @@ -1363,13 +1070,13 @@ private function peg_parseNamespaced_Block_Name() { $s1 = $this->peg_currPos; $s2 = $this->peg_parseBlock_Name_Part(); if ($s2 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c15) { - $s3 = $this->peg_c15; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) { + $s3 = $this->peg_c11; $this->peg_currPos++; } else { $s3 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c16); + $this->peg_fail($this->peg_c12); } } if ($s3 !== $this->peg_FAILED) { @@ -1410,7 +1117,7 @@ private function peg_parseCore_Block_Name() { } if ($s1 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f9($s1); + $s1 = $this->peg_f7($s1); } $s0 = $s1; @@ -1421,35 +1128,35 @@ private function peg_parseBlock_Name_Part() { $s0 = $this->peg_currPos; $s1 = $this->peg_currPos; - if (Gutenberg_PEG_peg_char_class_test($this->peg_c17, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c13, $this->input_substr($this->peg_currPos, 1))) { $s2 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s2 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c18); + $this->peg_fail($this->peg_c14); } } if ($s2 !== $this->peg_FAILED) { $s3 = array(); - if (Gutenberg_PEG_peg_char_class_test($this->peg_c19, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c15, $this->input_substr($this->peg_currPos, 1))) { $s4 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s4 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c20); + $this->peg_fail($this->peg_c16); } } while ($s4 !== $this->peg_FAILED) { $s3[] = $s4; - if (Gutenberg_PEG_peg_char_class_test($this->peg_c19, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c15, $this->input_substr($this->peg_currPos, 1))) { $s4 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s4 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c20); + $this->peg_fail($this->peg_c16); } } } @@ -1478,13 +1185,13 @@ private function peg_parseBlock_Attributes() { $s0 = $this->peg_currPos; $s1 = $this->peg_currPos; $s2 = $this->peg_currPos; - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c21) { - $s3 = $this->peg_c21; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c17) { + $s3 = $this->peg_c17; $this->peg_currPos++; } else { $s3 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c22); + $this->peg_fail($this->peg_c18); } } if ($s3 !== $this->peg_FAILED) { @@ -1493,13 +1200,13 @@ private function peg_parseBlock_Attributes() { $s6 = $this->peg_currPos; $this->peg_silentFails++; $s7 = $this->peg_currPos; - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c23) { - $s8 = $this->peg_c23; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c19) { + $s8 = $this->peg_c19; $this->peg_currPos++; } else { $s8 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c24); + $this->peg_fail($this->peg_c20); } } if ($s8 !== $this->peg_FAILED) { @@ -1514,28 +1221,28 @@ private function peg_parseBlock_Attributes() { $s9 = $this->peg_FAILED; } if ($s9 !== $this->peg_FAILED) { - $s10 = $this->peg_c25; + $s10 = $this->peg_c21; if ($s10 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c15) { - $s11 = $this->peg_c15; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) { + $s11 = $this->peg_c11; $this->peg_currPos++; } else { $s11 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c16); + $this->peg_fail($this->peg_c12); } } if ($s11 === $this->peg_FAILED) { $s11 = null; } if ($s11 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s12 = $this->peg_c5; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) { + $s12 = $this->peg_c7; $this->peg_currPos += 3; } else { $s12 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); + $this->peg_fail($this->peg_c8); } } if ($s12 !== $this->peg_FAILED) { @@ -1595,13 +1302,13 @@ private function peg_parseBlock_Attributes() { $s6 = $this->peg_currPos; $this->peg_silentFails++; $s7 = $this->peg_currPos; - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c23) { - $s8 = $this->peg_c23; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c19) { + $s8 = $this->peg_c19; $this->peg_currPos++; } else { $s8 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c24); + $this->peg_fail($this->peg_c20); } } if ($s8 !== $this->peg_FAILED) { @@ -1616,28 +1323,28 @@ private function peg_parseBlock_Attributes() { $s9 = $this->peg_FAILED; } if ($s9 !== $this->peg_FAILED) { - $s10 = $this->peg_c25; + $s10 = $this->peg_c21; if ($s10 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c15) { - $s11 = $this->peg_c15; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c11) { + $s11 = $this->peg_c11; $this->peg_currPos++; } else { $s11 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c16); + $this->peg_fail($this->peg_c12); } } if ($s11 === $this->peg_FAILED) { $s11 = null; } if ($s11 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c5) { - $s12 = $this->peg_c5; + if ($this->input_substr($this->peg_currPos, 3) === $this->peg_c7) { + $s12 = $this->peg_c7; $this->peg_currPos += 3; } else { $s12 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c6); + $this->peg_fail($this->peg_c8); } } if ($s12 !== $this->peg_FAILED) { @@ -1693,13 +1400,13 @@ private function peg_parseBlock_Attributes() { } } if ($s4 !== $this->peg_FAILED) { - if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c23) { - $s5 = $this->peg_c23; + if ($this->input_substr($this->peg_currPos, 1) === $this->peg_c19) { + $s5 = $this->peg_c19; $this->peg_currPos++; } else { $s5 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c24); + $this->peg_fail($this->peg_c20); } } if ($s5 !== $this->peg_FAILED) { @@ -1724,7 +1431,7 @@ private function peg_parseBlock_Attributes() { } if ($s1 !== $this->peg_FAILED) { $this->peg_reportedPos = $s0; - $s1 = $this->peg_f10($s1); + $s1 = $this->peg_f8($s1); } $s0 = $s1; @@ -1733,13 +1440,13 @@ private function peg_parseBlock_Attributes() { private function peg_parseWS() { - if (Gutenberg_PEG_peg_char_class_test($this->peg_c26, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c22, $this->input_substr($this->peg_currPos, 1))) { $s0 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s0 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c27); + $this->peg_fail($this->peg_c23); } } @@ -1748,13 +1455,13 @@ private function peg_parseWS() { private function peg_parseNewline() { - if (Gutenberg_PEG_peg_char_class_test($this->peg_c28, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c24, $this->input_substr($this->peg_currPos, 1))) { $s0 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s0 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c29); + $this->peg_fail($this->peg_c25); } } @@ -1763,13 +1470,13 @@ private function peg_parseNewline() { private function peg_parse_() { - if (Gutenberg_PEG_peg_char_class_test($this->peg_c30, $this->input_substr($this->peg_currPos, 1))) { + if (Gutenberg_PEG_peg_char_class_test($this->peg_c26, $this->input_substr($this->peg_currPos, 1))) { $s0 = $this->input_substr($this->peg_currPos, 1); $this->peg_currPos++; } else { $s0 = $this->peg_FAILED; if ($this->peg_silentFails === 0) { - $this->peg_fail($this->peg_c31); + $this->peg_fail($this->peg_c27); } } @@ -1824,35 +1531,31 @@ public function parse($input) { $this->peg_c0 = array("type" => "any", "description" => "any character" ); $this->peg_c1 = ""; - $this->peg_c6 = array( "type" => "literal", "value" => "-->", "description" => "\"-->\"" ); - $this->peg_c7 = ""; - $this->peg_c8 = array( "type" => "literal", "value" => "", "description" => "\"\"" ); - $this->peg_c9 = "wp:"; - $this->peg_c10 = array( "type" => "literal", "value" => "wp:", "description" => "\"wp:\"" ); - $this->peg_c11 = "/-->"; - $this->peg_c12 = array( "type" => "literal", "value" => "/-->", "description" => "\"/-->\"" ); - $this->peg_c13 = "/wp:"; - $this->peg_c14 = array( "type" => "literal", "value" => "/wp:", "description" => "\"/wp:\"" ); - $this->peg_c15 = "/"; - $this->peg_c16 = array( "type" => "literal", "value" => "/", "description" => "\"/\"" ); - $this->peg_c17 = array(array(97,122)); - $this->peg_c18 = array( "type" => "class", "value" => "[a-z]", "description" => "[a-z]" ); - $this->peg_c19 = array(array(97,122), array(48,57), array(95,95), array(45,45)); - $this->peg_c20 = array( "type" => "class", "value" => "[a-z0-9_-]", "description" => "[a-z0-9_-]" ); - $this->peg_c21 = "{"; - $this->peg_c22 = array( "type" => "literal", "value" => "{", "description" => "\"{\"" ); - $this->peg_c23 = "}"; - $this->peg_c24 = array( "type" => "literal", "value" => "}", "description" => "\"}\"" ); - $this->peg_c25 = ""; - $this->peg_c26 = array(array(32,32), array(9,9), array(13,13), array(10,10)); - $this->peg_c27 = array( "type" => "class", "value" => "[ \t\r\n]", "description" => "[ \t\r\n]" ); - $this->peg_c28 = array(array(13,13), array(10,10)); - $this->peg_c29 = array( "type" => "class", "value" => "[\r\n]", "description" => "[\r\n]" ); - $this->peg_c30 = array(array(32,32), array(9,9)); - $this->peg_c31 = array( "type" => "class", "value" => "[ \t]", "description" => "[ \t]" ); + $this->peg_c3 = "wp:"; + $this->peg_c4 = array( "type" => "literal", "value" => "wp:", "description" => "\"wp:\"" ); + $this->peg_c5 = "/-->"; + $this->peg_c6 = array( "type" => "literal", "value" => "/-->", "description" => "\"/-->\"" ); + $this->peg_c7 = "-->"; + $this->peg_c8 = array( "type" => "literal", "value" => "-->", "description" => "\"-->\"" ); + $this->peg_c9 = "/wp:"; + $this->peg_c10 = array( "type" => "literal", "value" => "/wp:", "description" => "\"/wp:\"" ); + $this->peg_c11 = "/"; + $this->peg_c12 = array( "type" => "literal", "value" => "/", "description" => "\"/\"" ); + $this->peg_c13 = array(array(97,122)); + $this->peg_c14 = array( "type" => "class", "value" => "[a-z]", "description" => "[a-z]" ); + $this->peg_c15 = array(array(97,122), array(48,57), array(95,95), array(45,45)); + $this->peg_c16 = array( "type" => "class", "value" => "[a-z0-9_-]", "description" => "[a-z0-9_-]" ); + $this->peg_c17 = "{"; + $this->peg_c18 = array( "type" => "literal", "value" => "{", "description" => "\"{\"" ); + $this->peg_c19 = "}"; + $this->peg_c20 = array( "type" => "literal", "value" => "}", "description" => "\"}\"" ); + $this->peg_c21 = ""; + $this->peg_c22 = array(array(32,32), array(9,9), array(13,13), array(10,10)); + $this->peg_c23 = array( "type" => "class", "value" => "[ \t\r\n]", "description" => "[ \t\r\n]" ); + $this->peg_c24 = array(array(13,13), array(10,10)); + $this->peg_c25 = array( "type" => "class", "value" => "[\r\n]", "description" => "[\r\n]" ); + $this->peg_c26 = array(array(32,32), array(9,9)); + $this->peg_c27 = array( "type" => "class", "value" => "[ \t]", "description" => "[ \t]" ); $peg_startRuleFunctions = array( 'Block_List' => array($this, "peg_parseBlock_List") ); $peg_startRuleFunction = array($this, "peg_parseBlock_List");