Skip to content

fix: #8 traverse child nodes when stripping p tags#21

Merged
KaiPrince merged 5 commits into
masterfrom
kprince/fix-strip-p-tags-child-nodes
Jan 1, 2026
Merged

fix: #8 traverse child nodes when stripping p tags#21
KaiPrince merged 5 commits into
masterfrom
kprince/fix-strip-p-tags-child-nodes

Conversation

@KaiPrince
Copy link
Copy Markdown
Contributor

@KaiPrince KaiPrince commented Dec 31, 2025

Summary

Fixes the bug mentioned in #8 (comment)

Context

The original implementation did not take the 11ty layout html into account, and only considered direct markdown input.

Changes

  • Traverses node children (except for custom elements)
  • Added child elements tests
Before After
image image

@KaiPrince
Copy link
Copy Markdown
Contributor Author

Hmm... it seems fixing the p stripping didn't fix the layout shift issue. Let me look into this further.

@KaiPrince KaiPrince marked this pull request as draft December 31, 2025 06:16
@KaiPrince
Copy link
Copy Markdown
Contributor Author

Ah, it looks like parse5 is stripping out the <head> because I'm using parseFragment. Will fix.

@KaiPrince
Copy link
Copy Markdown
Contributor Author

Okay I've fixed the head element being parsed out, but it's still broken. But the html looks identical. What a tricky pickle. So far what I've noticed is removing the height 100% in the browser fixes the layout, so maybe that's a hint
image

@thescientist13
Copy link
Copy Markdown
Member

Thanks for looking into this and yeah, good catch on the <head> behavior! Let me play around with a little bit more and see if I can spot anything. 👀

@thescientist13 thescientist13 changed the title fix: traverse child nodes when stripping p tags fix: #8 traverse child nodes when stripping p tags Dec 31, 2025
@thescientist13 thescientist13 linked an issue Dec 31, 2025 that may be closed by this pull request
@thescientist13 thescientist13 added the bug Something isn't working label Dec 31, 2025
@thescientist13
Copy link
Copy Markdown
Member

thescientist13 commented Dec 31, 2025

My initial hunch is that maybe since the component is not wrapped up in a block level element anymore (the <p> tag) the CSS is slightly off? I just tested this fix and I am fine with removing height in the starter repo. I diffed the HTML output and it all looks as expected, so feeling good with the behavior of the plugin, at least.

Copy link
Copy Markdown
Member

@thescientist13 thescientist13 left a comment

Choose a reason for hiding this comment

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

I think this looks good to me, if you feel good to undraft.

@KaiPrince KaiPrince marked this pull request as ready for review December 31, 2025 23:41
@KaiPrince
Copy link
Copy Markdown
Contributor Author

KaiPrince commented Dec 31, 2025

Oh right, this actually builds off #20 , so it needs to wait for that. (If #20 takes too long, I'll just un-base this one)

@thescientist13
Copy link
Copy Markdown
Member

Sounds good, we can work through that one first 👍

Base automatically changed from kprince/add-basic-tests to master January 1, 2026 01:06
@KaiPrince KaiPrince force-pushed the kprince/fix-strip-p-tags-child-nodes branch from 3251a29 to 7217fb7 Compare January 1, 2026 01:09
@netlify
Copy link
Copy Markdown

netlify Bot commented Jan 1, 2026

Deploy Preview for legendary-starlight-75451b ready!

Name Link
🔨 Latest commit 75c1c3f
🔍 Latest deploy log https://app.netlify.com/projects/legendary-starlight-75451b/deploys/6955c9abb056f20008105203
😎 Deploy Preview https://deploy-preview-21--legendary-starlight-75451b.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@KaiPrince KaiPrince force-pushed the kprince/fix-strip-p-tags-child-nodes branch from 7217fb7 to 75c1c3f Compare January 1, 2026 01:11
@KaiPrince KaiPrince merged commit 0c6f4bc into master Jan 1, 2026
8 checks passed
@KaiPrince KaiPrince deleted the kprince/fix-strip-p-tags-child-nodes branch January 1, 2026 01:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.2.1 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

avoid wrapping custom elements in <p> tags

2 participants