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

Macros related to lists appear to have no effect #31

Open
groenroos opened this issue Dec 5, 2024 · 1 comment · May be fixed by #32
Open

Macros related to lists appear to have no effect #31

groenroos opened this issue Dec 5, 2024 · 1 comment · May be fixed by #32
Assignees
Labels
bug Something isn't working

Comments

@groenroos
Copy link

Description of the bug

When trying to apply a macro to the list elements in my HTML, they seem to have no effect in the final HTML:

Block_Converter::macro( 'ol', function ( \DOMNode $node ) {
	/* Convert to paragraph just to see if it works */
	return new Block( 'core/paragraph', [], $node->textContent );
} );
<!-- wp:heading {"level":2} --><h2>Test content</h2><!-- /wp:heading -->

<!-- wp:list {"ordered":true} --><ol>
<li>
<p>Foo</p>
</li>
<li>
<p>Bar</p>
</li>
</ol><!-- /wp:list -->

The same happens regardless of whether the macro is targeting "ol", "li", or "ul".

However, the exact same macro targeting "h2" does work:

Block_Converter::macro( 'h2', function ( \DOMNode $node ) {
	/* Convert to paragraph just to see if it works */
	return new Block( 'core/paragraph', [], $node->textContent );
} );
<!-- wp:paragraph -->Test content<!-- /wp:paragraph -->

<!-- wp:list {"ordered":true} --><ol>
<li>
<p>Foo</p>
</li>
<li>
<p>Bar</p>
</li>
</ol><!-- /wp:list -->

Steps To Reproduce

  1. Use the test HTML below
  2. Write a macro attempting to affect the conversion of <ol> and/or <li> tags
  3. $converter = new Block_Converter( $html ); return $converter->convert();
  4. The resulting HTML will look identical to when no macro is present - i.e. the macro wasn't applied

Additional Information

Test HTML:

$html = "<h2>Test content</h2>\n<ol>\n<li>\n<p>Foo</p>\n</li>\n<li>\n<p>Bar</p>\n</li>\n</ol>\n";
@groenroos groenroos added the bug Something isn't working label Dec 5, 2024
@srtfisher srtfisher self-assigned this Dec 11, 2024
@srtfisher srtfisher linked a pull request Dec 13, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants
@srtfisher @groenroos and others