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

inline prop is not available from React Markdown since 9.0.0 #7

Open
AVGVSTVS96 opened this issue Feb 1, 2025 · 0 comments
Open

inline prop is not available from React Markdown since 9.0.0 #7

AVGVSTVS96 opened this issue Feb 1, 2025 · 0 comments

Comments

@AVGVSTVS96
Copy link

This is a really cool project, I was looking through the code and noticed that you're using the inline prop in combination with isCodeBlock to determine if code is inline. I ran into this issue when implementing syntax highlighting in my own chat project, inline was removed in 9.0.0, using isCodeBlock alone should be enough to cover most cases, but what I did in my project was write a rehype plugin to add the inline prop if the parent div isn't a pre element:

export function rehypeInlineCodeProperty() {
  return function (tree: Root): undefined {
    visit(tree, 'element', function (node: Element, _index, parent: Element) {
      if (parent && parent.tagName === 'pre') {
        node.properties.inline = false;
      } else {
        node.properties.inline = true;
      }
    });
  }
}

I think isCodeBlock is fine on it's own, but adding this rehype plugin could help cover edge cases. I'd be happy to make a PR if you want to go this direction, at the very least we can remove inline.

Reproduce: Add console.log(inline) and see that it's value is undefined when inline code is rendered.

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