interweave icon indicating copy to clipboard operation
interweave copied to clipboard

Transform Docs Update Suggestions

Open jamesmart77 opened this issue 2 years ago • 0 comments

Hey there! Awesome library!

After to digging around a little because my transform function wasn't working like I expected based from the docs example, I thought offering a suggestion would be helpful.

Since the reference a tagName === 'a', I expected just that, a lowercase 'a'. But turns out tagNames are actually uppercase. So maybe one of the following changes?

function transform(node: HTMLElement, children: Node[]): React.ReactNode {
    if (node.tagName === 'A') {
        return <Link href={node.getAttribute('href')}>{children}</Link>;
    }
}

OR

function transform(node: HTMLElement, children: Node[]): React.ReactNode {
    if (node.tagName.toLowerCase() === 'a') {
        return <Link href={node.getAttribute('href')}>{children}</Link>;
    }
}

jamesmart77 avatar Oct 12 '22 11:10 jamesmart77