Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transform Docs Update Suggestions #237

Open
jamesmart77 opened this issue Oct 12, 2022 · 0 comments
Open

Transform Docs Update Suggestions #237

jamesmart77 opened this issue Oct 12, 2022 · 0 comments

Comments

@jamesmart77
Copy link

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>;
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant