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

[gatsby-source-wordpress] image between the code blocks are not replaced properly #30595

Closed
raku444 opened this issue Mar 31, 2021 · 3 comments
Closed
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby

Comments

@raku444
Copy link

raku444 commented Mar 31, 2021

Description

It seems similar to #29687, but image are not replaced when image between code blocks.

Steps to reproduce

Order of blocks in the wordpress 5.7 gutenberg editor:

  • Code Block
  • Image Block
  • Code Block

Gatsby output with gatsby-starter-wordpress-blog:

code-and-img

<pre class="wp-block-code"><code>...</code></pre>

<figure class="wp-block-image size-large">
<img loading="lazy" width="1024" height="683" 
src="http://192.168.0.24:8020/wp-content/uploads/2021/02/spice-1024x683.jpg" alt="" class="wp-image-5708" 
srcset="http://192.168.0.24:8020/wp-content/uploads/2021/02/spice-1024x683.jpg 1024w, http://192.168.0.24:8020/wp-content/uploads/2021/02/spice-300x200.jpg 300w, http://192.168.0.24:8020/wp-content/uploads/2021/02/spice-768x512.jpg 768w, http://192.168.0.24:8020/wp-content/uploads/2021/02/spice.jpg 1500w" sizes="(max-width: 1024px) 100vw, 1024px">
</figure>

<pre class="wp-block-code"><code>...</code></pre>

Expected result

The image should be replaced with gatsby-image & a static/ url

Actual result

The image were not replaced.

Same result even if other blocks are between image and code, regardless of the content of the blocks.

Also HTML blocks with "pre" or "code" tag seems to cause the same problem.

Environment

System:
OS: Linux 3.10 CentOS Linux 7 (Core)
CPU: (2) x64 Intel(R) Xeon(R) CPU E31260L @ 2.40GHz
Shell: 4.2.46 - /bin/bash
Binaries:
Node: 12.20.0 - ~/.nvm/versions/node/v12.20.0/bin/node
Yarn: 1.22.5 - ~/.yarn/bin/yarn
npm: 6.14.8 - ~/.nvm/versions/node/v12.20.0/bin/npm
Languages:
Python: 2.7.5 - /usr/bin/python
Browsers:
Chrome: 78.0.3904.70
npmPackages:
gatsby: ^3.2.0 => 3.2.0
gatsby-image: ^3.2.0 => 3.2.0
gatsby-plugin-manifest: ^3.2.0 => 3.2.0
gatsby-plugin-offline: ^4.2.0 => 4.2.0
gatsby-plugin-react-helmet: ^4.2.0 => 4.2.0
gatsby-plugin-sharp: ^3.2.0 => 3.2.0
gatsby-source-filesystem: ^3.2.0 => 3.2.0
gatsby-source-wordpress: ^5.2.0 => 5.2.0
gatsby-transformer-sharp: ^3.2.0 => 3.2.0
npmGlobalPackages:
gatsby-cli: 3.2.0

@raku444 raku444 added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 31, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Mar 31, 2021
@LekoArts LekoArts added topic: source-wordpress Related to Gatsby's integration with WordPress and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Apr 6, 2021
@raku444
Copy link
Author

raku444 commented Apr 18, 2021

Is Line 478 of the following code causing this problem...?

https://github.com/gatsbyjs/gatsby/pull/29778/files

/<code([\w\W]+?)[\/]?>.*(<\/code>)/gim

test

  1. Order of blocks in the WordPress 5.7 Gutenberg editor:
  • Code Block
  • Image Block
  • Code Block
  1. HTML output by WordPress:
<pre class="wp-block-code"><code>TEST TEST TEST</code></pre>

<figure class="wp-block-image size-large"><img loading="lazy" width="1024" height="665" src="http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-1024x665.jpg" alt="" class="wp-image-6" srcset="http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-1024x665.jpg 1024w, http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-300x195.jpg 300w, http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-768x499.jpg 768w, http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-1536x998.jpg 1536w, http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920-1568x1018.jpg 1568w, http://192.168.0.24:8020/wp-content/uploads/2021/04/green-5919790_1920.jpg 1920w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>

<pre class="wp-block-code"><code>コード コード コード</code></pre>

  1. If apply the code in line 478 to the HTML output, it will look like this:
    https://regex101.com/
    code

@github-actions
Copy link

github-actions bot commented May 8, 2021

Hiya!

This issue has gone quiet. Spooky quiet. 👻

We get a lot of issues, so we currently close issues after 60 days of inactivity. It’s been at least 20 days since the last update here.
If we missed this issue or if you want to keep it open, please reply here.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks for being a part of the Gatsby community! 💪💜

@github-actions github-actions bot added the stale? Issue that may be closed soon due to the original author not responding any more. label May 8, 2021
@github-actions
Copy link

Hey again!

It’s been 60 days since anything happened on this issue, so our friendly neighborhood robot (that’s me!) is going to close it.
Please keep in mind that I’m only a robot, so if I’ve closed this issue in error, I’m HUMAN_EMOTION_SORRY. Please feel free to comment on this issue or create a new one if you need anything else.
As a friendly reminder: the best way to see this issue, or any other, fixed is to open a Pull Request. Check out gatsby.dev/contribute for more information about opening PRs, triaging issues, and contributing!

Thanks again for being part of the Gatsby community! 💪💜

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more. topic: source-wordpress Related to Gatsby's integration with WordPress type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

2 participants