apostrophecms / sanitize-html

Clean up user-submitted HTML, preserving whitelisted elements and whitelisted attributes on a per-element basis. Built on htmlparser2 for speed and tolerance
MIT License
3.79k stars 353 forks source link

Can I use sanitizeHtml with NextJS Link #508

Closed vadimsabadosh closed 2 years ago

vadimsabadosh commented 2 years ago

Can I use sanitizeHtml with NextJS Link something like this?

const cleanHtml = sanitizeHtml(text, {
        transformTags: {
            a: (tagName, attribs) => {
                return `<Link href=${attribs.href}><a>${tagName.text}</a></Link>`
            }
        }
    })

As a result, I need the a tag to work as a Link tag in nextjs

abea commented 2 years ago

We might be missing the ability to allow capitalized tags. I tried altering a test to include one and it didn't pass. If that doesn't work it'd be a potential enhancement. The rest looks like it should work fine.

vadimsabadosh commented 2 years ago

@abea thanks a lot for the answer