Skip to content

gatsby-remark-images nests figure in p #36211

@schwigri

Description

@schwigri

Preliminary Checks

Description

When using gatsby-remark-images along with the showCaptions feature, it creates a figure element which is nested inside a p, which is not valid HTML.

This issue has been reported before: #16239

The latest comment on that issue said to open a new bug if this still exists in Gatsby 4, so I have created minimal reproduction from gatsby-starter-blog and setting showCaptions to true.

Reproduction Link

https://github.com/schwigri/gatsby-starter-blog

Steps to Reproduce

  1. npm run develop or npm run build && npm run serve
  2. See the HTML for the post "Hello World"
  3. The image with the eggs will be a figure element that is nested inside a p element.
  4. Please view the raw HTML itself; modern browser realizes that this is incorrect and moves the figure outside of the paragraph, leaving an empty paragraph so the dev tools will show it like <p></p><figure />

Expected Result

<figure />

Actual Result

<p>
    <figure />
</p>

Environment

System:
    OS: Linux 5.18 Arch Linux
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1185G7 @ 3.00GHz
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.16.0 - ~/.nvm/versions/node/v16.16.0/bin/node
    npm: 8.11.0 - ~/.nvm/versions/node/v16.16.0/bin/npm
  Languages:
    Python: 3.10.5 - /usr/bin/python
  Browsers:
    Firefox: 102.0.1
  npmPackages:
    gatsby: ^4.19.2 => 4.19.2 
    gatsby-plugin-feed: ^4.19.0 => 4.19.0 
    gatsby-plugin-gatsby-cloud: ^4.19.0 => 4.19.0 
    gatsby-plugin-google-analytics: ^4.19.0 => 4.19.0 
    gatsby-plugin-image: ^2.19.0 => 2.19.0 
    gatsby-plugin-manifest: ^4.19.0 => 4.19.0 
    gatsby-plugin-offline: ^5.19.0 => 5.19.0 
    gatsby-plugin-react-helmet: ^5.19.0 => 5.19.0 
    gatsby-plugin-sharp: ^4.19.0 => 4.19.0 
    gatsby-remark-copy-linked-files: ^5.19.0 => 5.19.0 
    gatsby-remark-images: ^6.19.0 => 6.19.0 
    gatsby-remark-prismjs: ^6.19.0 => 6.19.0 
    gatsby-remark-responsive-iframe: ^5.19.0 => 5.19.0 
    gatsby-remark-smartypants: ^5.19.0 => 5.19.0 
    gatsby-source-filesystem: ^4.19.0 => 4.19.0 
    gatsby-transformer-remark: ^5.19.0 => 5.19.0 
    gatsby-transformer-sharp: ^4.19.0 => 4.19.0

Config Flags

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssue with a clear description that the community can help with.status: confirmedIssue with steps to reproduce the bug that’s been verified by at least one reviewer.topic: remark/mdxRelated to Markdown, remark & MDX ecosystemtype: bugAn issue or pull request relating to a bug in Gatsby

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions