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

custom html component render in a wrong way #889

Closed
4 tasks done
byk11 opened this issue Feb 11, 2025 · 10 comments
Closed
4 tasks done

custom html component render in a wrong way #889

byk11 opened this issue Feb 11, 2025 · 10 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@byk11
Copy link

byk11 commented Feb 11, 2025

Initial checklist

Affected package

"react-markdown": "^8.0.5" "rehype-raw": "^7.0.0",

Steps to reproduce

Image The position of the think component in the DOM tree is incorrect. How could I fix it, help please

Actual behavior

Image The position of the think component in the DOM tree is incorrect. How could I fix it, help please

Expected behavior

think about something,think about something

think about something,think about something

think component only wrap his children

Runtime

https://remarkjs.github.io/react-markdown/#html-in-markdown

Package manager

pnpm@8

Operating system

mac

Build and bundle tools

No response

@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 Feb 11, 2025
@ChristianMurphy
Copy link
Member

ChristianMurphy commented Feb 11, 2025

@byk11 could you share the HTML/markdown you are using?
The screenshot, doesn't offer a lot of clarity on what you expect.
One thing I do see is you have invalid HTML <think>, custom elements in HTML must contain a dash. https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#name

@ChristianMurphy ChristianMurphy added the 🙉 open/needs-info This needs some more info label Feb 11, 2025

This comment has been minimized.

@byk11
Copy link
Author

byk11 commented Feb 11, 2025

@byk11 could you share the HTML/markdown you are using? The screenshot, doesn't offer a lot of clarity on what you expect. One thing I do see is you have invalid HTML <think>, custom elements in HTML must contain a dash. https://developer.mozilla.org/en-US/docs/Web/API/Web_components/Using_custom_elements#name

@ChristianMurphy thank you for your reply.
this is my markdown:


other content,other content

<my-think>
think about something,think about something

think about something,think about something
</my-think>

other content,other content

other content,other content
Image

@ChristianMurphy
Copy link
Member

@byk11 could share your content in a code block?

```
example <my-think>test</my-think>
```

@byk11
Copy link
Author

byk11 commented Feb 11, 2025

@ChristianMurphy sure!


other content,other content

<my-think>
think about something,think about something

think about something,think about something
</my-think>

other content,other content

other content,other content

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Feb 11, 2025

@byk11 thanks for adding the code block.
To clarify, you are asking about the paragraphs in the HTML tag?
That is how markdown works, HTML can mix markdown inside. Paragraphs are being generated by the newlines.

<my-think>

# think **about** something,think about something

think `about` something,think about something

</my-think>

rendered


think about something,think about something

think about something,think about something

@ChristianMurphy ChristianMurphy added 🙋 no/question This does not need any changes and removed 🙉 open/needs-info This needs some more info labels Feb 11, 2025
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Feb 11, 2025

This comment has been minimized.

Copy link

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 the 👎 phase/no Post cannot or will not be acted on label Feb 11, 2025
@byk11
Copy link
Author

byk11 commented Feb 11, 2025

@ChristianMurphy I want to render a custom Think components

Image

@ChristianMurphy sure!


other content,other content

<my-think>
think about something,think about something

think about something,think about something
</my-think>

other content,other content

other content,other content

@ChristianMurphy thank you. I want to render a custom think component to display what AI is thinking about. The content is from AI. Maybe I can add a '\n' before , but is there any better resolution to cover more scenarios?I found that the following three situations cannot be displayed normally.


other content,other content

<my-think>think about something,think about something

think about something,think about something
</my-think>

other content,other content

other content,other content

other content,other content

<my-think>think about something,think about something

think about something,think about something

</my-think>

other content,other content

other content,other content

other content,other content

<my-think>
think about something,think about something

think about something,think about something
</my-think>

other content,other content

other content,other content
Image

@ChristianMurphy
Copy link
Member

A few thoughts:

  1. make sure my-think's component supports arbitrary content, that could contain markdown
  2. do you control the fine-tuning or prompting for the thinking tokens of your model? If so consider prompting or fine tuning it to produce valid markdown!
  3. If not (unfortunate) you could indeed try to message the content to make it valid markdown, adding newlines.

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

2 participants