Skip to content

feat: #8 config option to strip wrapping paragraphs#16

Merged
thescientist13 merged 6 commits into
masterfrom
kprince/strip-p-tags
Dec 30, 2025
Merged

feat: #8 config option to strip wrapping paragraphs#16
thescientist13 merged 6 commits into
masterfrom
kprince/strip-p-tags

Conversation

@KaiPrince

Copy link
Copy Markdown
Contributor

Summary

Adds a utility function to remove wrapping <p> tags around custom elements for markdown files. Also added tests.

Resolves #8 .

@netlify

netlify Bot commented Dec 11, 2025

Copy link
Copy Markdown

Deploy Preview for legendary-starlight-75451b ready!

Name Link
🔨 Latest commit 3e5ade4
🔍 Latest deploy log https://app.netlify.com/projects/legendary-starlight-75451b/deploys/69532b9d4a1fca0008ce6883
😎 Deploy Preview https://deploy-preview-16--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.

Comment thread package-lock.json

This comment was marked as outdated.

Comment thread src/index.js
Comment on lines -12 to +13
eleventyConfig.addTransform('wcc', async (content, outputPath) => {
eleventyConfig.addTransform('wcc', async function (content, outputPath) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Needed to change to anonymous function to support this

@KaiPrince

KaiPrince commented Dec 11, 2025

Copy link
Copy Markdown
Contributor Author

Hmm, I’ll have to look into this. It’s working fine on my machine. My guess is I have a different node or 11ty version installed.

html.replaceAll is not a function

edit: yup didn’t notice this was a node 14 project

@KaiPrince

Copy link
Copy Markdown
Contributor Author

@thescientist13 Do you know why the CI keeps timing out?

@KaiPrince KaiPrince force-pushed the kprince/strip-p-tags branch from 5e9d671 to dd72d4b Compare December 16, 2025 06:06

@thescientist13 thescientist13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this @KaiPrince !

Did just want to call out that the project is pretty far behind in dependencies (specifically 11ty and WCC) and so it still seemed prudent to do that first, which I have done in #17 .

One big benefit is that we can make this entire project ESM now. So if you want to check that one out, I would like to merge that one first probably


Interestingly, I don't see the wrapping <p> tags in the starter kit?
https://github.com/thescientist13/eleventy-starter-wcc

Also, and maybe because the local dev / node version was not defined in this repo, on main branch of this repo I was seeing the wrapping tags but nothing in the demo output. It seems the greeting.js file wasn't loading?
Image

But after that upgrade, I do?
Image

Probably still nice to have this feature though, so maybe after we land #17 , we can rebase and add this work.

Let me know your thoughts.

Comment thread package.json Outdated
{
"name": "eleventy-plugin-wcc",
"version": "0.1.0",
"version": "0.1.1",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we shouldn't be bumping package.json as part of PRs

Comment thread README.md
## Options

Coming soon!
`trimParagraphTagsInMd` (bool, default true) - Trims unexpected `<p>` tags that markdown puts around custom elements [more details](https://github.com/ProjectEvergreen/eleventy-plugin-wcc/issues/8).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Interesting, for Greenwood we do it automatically. I guess it can't hurt to have it be an option

Comment thread src/utils.js Outdated
@@ -0,0 +1,32 @@
const parse5 = require('parse5');

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

any reason we are using CJS here, and not ESM?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

oh right, 11ty didn't support ESM until v3
https://www.11ty.dev/blog/eleventy-v3/

Comment thread package.json Outdated
"scripts": {
"clean": "rimraf ./_site",
"lint": "eslint \"src/**/*.js\" \"demo/**/*.js\"",
"test": "jest",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

could we just use node test runner here? Maybe we start with adding test cases for what's there currently as part of #3?

@thescientist13 thescientist13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

OK, #17 has been merged, this will need a rebase (or maybe a restart, depending on how bad the diff is). I think a rebase (or now PR) should definitely re-trigger CI, since it was maybe just a glitch on the GitHub side.

Might be nice to start with #3 as a PR, using Node test runner?

@thescientist13 thescientist13 added documentation Improvements or additions to documentation enhancement New feature or request labels Dec 23, 2025
@thescientist13 thescientist13 changed the title fix: strip wrapping paragraphs feat: #8 config option to strip wrapping paragraphs Dec 23, 2025
add markdown only check

chore: add tests

Add test for multiple components.

switch to parse5 implementation

inspired by https://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454

Switch to node test runner

remove jest

revert version bump

fix after rebase
@KaiPrince KaiPrince force-pushed the kprince/strip-p-tags branch from dd72d4b to 7be1314 Compare December 28, 2025 17:17
Comment thread package.json Outdated
"devDependencies": {
"@11ty/eleventy": "^3.1.0",
"eslint": "^8.18.0",
"parse5": "^8.0.0",

@thescientist13 thescientist13 Dec 30, 2025

Copy link
Copy Markdown
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 a standard dependency, no?

Comment thread .github/workflows/ci.yml
- name: Lint
run: |
npm run lint
- name: Test

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@KaiPrince
Added the test command to GitHub Actions

@thescientist13 thescientist13 linked an issue Dec 30, 2025 that may be closed by this pull request

@thescientist13 thescientist13 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks! I just updated GitHub Actions to run tests and moved parse5 to be a dependency since we use it first party in our code.

@thescientist13 thescientist13 merged commit 8c1ef76 into master Dec 30, 2025
8 checks passed
@thescientist13 thescientist13 deleted the kprince/strip-p-tags branch December 30, 2025 01:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

avoid wrapping custom elements in <p> tags add basic test cases

2 participants