-
Notifications
You must be signed in to change notification settings - Fork 24
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
Support code syntax highlighter #52
Comments
I'm not familiar with that package, but from what it seems it expects a raw string, and not a HTML element. import SyntaxHighlighter from 'react-syntax-highlighter';
import { docco } from 'react-syntax-highlighter/dist/esm/styles/hljs';
const Component = () => {
const codeString = '(num) => num + 1';
return (
<SyntaxHighlighter language="javascript" style={docco}>
{codeString}
</SyntaxHighlighter>
);
}; The Unless you only type out stuff once and then fully remount the animation. In that case you could get it working by constantly monitoring the typed out content for a code snippet via the MutationObserver API for example, and then splitting the typed out animation text by that code snipped and injecting that Document before
Document after:
But keep in mind that only the I know it's super hacky 😐 As an alternative, maybe you could use something like a React markdown renderer/formatter, and make your type animation type the code in markdown format, like this: " You could then pass a React const innerText = someRef.current?.innerText;
<>
<div style={{display:"none"}}>
<TypeAnimation ref={someRef}/>
</div>
<Markdown>
{innerText}
</Markdown/>
</> Now I know this is far from optimal. Really need to add an animation hook that exports a responsive string of the rendered text... |
What is the current status of this issue? |
Great library!
As you support similar feature like chatgpt I was wondering if we can also support a code syntax highlighter when the text is code.
Tried to make it working with the syntax-highlighter but unfortunately it's not something doable.
Any hints how to do this?
The text was updated successfully, but these errors were encountered: