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

sup element rendering with remark-gfm plugin is painfully slow. #827

Closed
4 tasks done
tgram-3D opened this issue May 6, 2024 · 7 comments
Closed
4 tasks done

sup element rendering with remark-gfm plugin is painfully slow. #827

tgram-3D opened this issue May 6, 2024 · 7 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@tgram-3D
Copy link

tgram-3D commented May 6, 2024

Initial checklist

Affected packages and versions

react-markdown 9.0.1, remark-gfm 4.0.0

Link to runnable example

No response

Steps to reproduce

I'm using ReactMarkdown to render streaming LLM tokens, which seems to be a common use-case, and I'm trying to get it to render footnotes correctly. It works, but basically the entire paragraph renders fine in markdown but the [^1], [^2] formatted footnotes just sit there basically and don't get rendered as sup until the entire p element is complete.

<ReactMarkdown
                        remarkPlugins={[remarkGfm, remarkMath]}
                        rehypePlugins={[
                            rehypeKatex,
                            [
                                //@ts-expect-error version 6.0.0
                                rehypeHighlight,
                                {
                                    detect: true,
                                    ignoreMissing: true,
                                    subset: codeLanguageSubset
                                }
                            ]
                        ]}
                        components={components}
                    >
                        {content}
                    </ReactMarkdown>

I tried a custom component for sup and same deal. Is there a better way to do this sort of thing? I'm thinking I just get rid of remarkGfm and target superscript formatting in my custom p component directly, but it seems like there should be a better solution.

One thing that's kind of interesting is the back-ref a tags in the footnotes section render just fine, but not the actual sup elements.

Using node 20.12.0 and npm 10.5.0

Expected behavior

Footnotes rendered on streaming.

Actual behavior

Footnote rendering lags significantly and doesn't work until entire paragraph element is rendered.

Runtime

Other (please specify in steps to reproduce)

Package manager

Other (please specify in steps to reproduce)

OS

Windows

Build and bundle tools

Vite

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels May 6, 2024
@wooorm
Copy link
Member

wooorm commented May 6, 2024

It is unclear what you see because you have not shared what you see.

@wooorm wooorm added the 🙊 open/needs-repro This needs a reproduction label May 6, 2024

This comment has been minimized.

@remcohaszing
Copy link
Member

Markdown can’t be streamed. Footnotes and definitions can appear at the end of a document, meaning the entire markdown document needs to be parsed in order to know whether or not something that looks like a footnote reference of link reference is actually a reference or just plain text.

This doesn’t stop people from streaming markdown anyway.


This paragraph has only one footnote[^1][^2].

[^1]: Footnote

This paragraph has only one footnote1[^2].

Footnotes

  1. Footnote

@wooorm
Copy link
Member

wooorm commented May 6, 2024

This is what I am assuming too.

Nothing is “painful” here. You’re just streaming things and observe that things are streamed.

@tgram-3D
Copy link
Author

tgram-3D commented May 6, 2024

Markdown can’t be streamed. Footnotes and definitions can appear at the end of a document, meaning the entire markdown document needs to be parsed in order to know whether or not something that looks like a footnote reference of link reference is actually a reference or just plain text.

This doesn’t stop people from streaming markdown anyway.

This paragraph has only one footnote[^1][^2].

[^1]: Footnote

This paragraph has only one footnote1[^2].

Footnotes

  1. Footnote

Ah, duh. That makes sense. I guess I don't understand how it's actually inferring the href for the a tags in the footnotes, cause I'm seeing the same behavior with totally fake content. I'll mark this as closed and figure something else out. Thanks for the replies.

@tgram-3D tgram-3D closed this as completed May 6, 2024

This comment has been minimized.

@wooorm wooorm added the 🙋 no/question This does not need any changes label May 6, 2024
Copy link

github-actions bot commented May 6, 2024

Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.

See our support docs for how and where to ask questions.

Thanks,
— bb

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually 🙊 open/needs-repro This needs a reproduction labels May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

3 participants