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

Parser: Parse <!-- more --> tag and <!-- noteaser --> #1460

Merged
merged 5 commits into from
Jul 4, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
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
25 changes: 24 additions & 1 deletion blocks/api/post.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,33 @@ WP_Block_List
= WP_Block*

WP_Block
= WP_Block_Void
= WP_Tag_More
/ WP_Block_Void
/ WP_Block_Balanced
/ WP_Block_Html

WP_Tag_More
= "<!--" WS* "more" customText:(WS+ text:$((!(WS* "-->") .)+) { /** <?php return $text; ?> **/ return text })? WS* "-->" noTeaser:(WS* "<!--noteaser-->")?
{ /** <?php
return array(
'blockName' => 'wp:core/more',
'attrs' => array(
'customText' => $customText,
'noTeaser' => (bool) $noTeaser
),
'rawContent' => ''
);
?> **/
return {
blockName: 'wp:core/more',
attrs: {
customText: customText,
noTeaser: !! noTeaser
},
rawContent: ''
}
}

WP_Block_Void
= "<!--" WS+ "wp:" blockName:WP_Block_Name WS+ attrs:(a:WP_Block_Attributes WS+ {
/** <?php return $a; ?> **/
Expand Down
4 changes: 4 additions & 0 deletions blocks/api/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ export function serializeBlock( block ) {
const saveContent = getSaveContent( blockType, block.attributes );
const saveAttributes = getCommentAttributes( block.attributes, parseBlockAttributes( saveContent, blockType ) );

if ( 'wp:core/more' === blockName ) {
return `<!-- more ${ saveAttributes.customText ? `${ saveAttributes.customText } ` : '' }-->${ saveAttributes.noTeaser ? '\n<!--noteaser-->' : '' }`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should actually be <!--more instead of <!-- more according to get_the_content().

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in #1440.

}

const serializedAttributes = ! isEmpty( saveAttributes )
? serializeAttributes( saveAttributes ) + ' '
: '';
Expand Down
Loading