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

Updated markdown libraries and fixed breaking changes and type issues #415

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jb-dev1
Copy link
Contributor

@jb-dev1 jb-dev1 commented Sep 8, 2024

Summary:

This PR updates the markdown-related libraries (react-markdown, remark-gfm, and remark-math) and addresses the resulting breaking changes caused by the upgrades. Fixes #414.

Changes:

  1. Inline vs Block Code Handling:

    • The inline prop is no longer passed by react-markdown (v9.x+). We now determine whether a code block is inline by checking for the absence of a className attribute.
    • Added a fallback class "inline-code" for inline code blocks to maintain consistent styling.
  2. Safe Access to children Prop:

    • Added safety checks to ensure that children is defined, is an array, and handled correctly (e.g., checking children.length or replacing its first element). This avoids potential runtime errors where children could be null or undefined.
    • Adjusted the handling of children and other props to conform to strict type checking, ensuring that we account for possible null or undefined values in rendering components.
  3. Special Character Handling:

    • Retained logic to replace occurrences of with a pulse animation for custom rendering, ensuring compatibility with the updated react-markdown behavior.
    • Safeguarded this replacement logic by first checking that children[0] exists and is a string.

Affected Files:

  • components/stocks/message.tsx: Fixed handling of inline vs block code and added null checks for children.
  • components/chat-message.tsx (although unused): Applied similar fixes to handle breaking changes from react-markdown and ensure type safety so that build would not fail since this file is included.

Testing:

  • Successfully built the project after applying changes.
  • Verified correct rendering of both inline and block code snippets in user and bot messages.

- provided fixes for breaking changes
- addressed type safety concerns
Copy link

vercel bot commented Sep 8, 2024

Someone is attempting to deploy a commit to the Uncurated Tests Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

New and removed dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] Transitive: environment +80 2.61 MB wooorm
npm/[email protected] Transitive: environment +67 2.34 MB wooorm
npm/[email protected] Transitive: environment, filesystem, shell +55 6 MB wooorm

🚮 Removed packages: npm/[email protected]), npm/[email protected]), npm/[email protected])

View full report↗︎

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

Successfully merging this pull request may close these issues.

Very old markdown processing libraries
2 participants