How do I use html-react-parser with <Highlight attribute="description" hit={hit} /> ? #5749
Replies: 7 comments 5 replies
-
The highlight component specifically escapes html, as they are generally a danger. You can either:
Both of those options will require you to pass |
Beta Was this translation helpful? Give feedback.
-
Sorry that still doesn't work. I have tried this:
Any ideas? |
Beta Was this translation helpful? Give feedback.
-
Cool, I am getting closer. I am able to output the parsed result with this:
However want the result pass into the I noticed the once adding See screen shot below. The bold title is what is being distorted. It should say 202 Pendant. |
Beta Was this translation helpful? Give feedback.
-
Using What about cleaning up the code to pass the parsed result to the component? Thank you! |
Beta Was this translation helpful? Give feedback.
-
The output to the browser is how i want it. It's the code that I have questions about. My question is shouldn't I be passing the parsed value to |
Beta Was this translation helpful? Give feedback.
-
Ok. I think I understand. Isn't it common the have descriptions with html? I feel doing this process should have been simpler. |
Beta Was this translation helpful? Give feedback.
-
The product description comes from a CMS Rich Text Editor field (CKEditor 5). We wanted user to be able to format the text and add link etc... That why it outputs HTML. |
Beta Was this translation helpful? Give feedback.
-
Hello ,
I am using
react-instantsearch-hooks-web
In my DB i have HTML string as the description. I need to parse it so it output as HTML and not output the tags.
I want to use the component
<Highlight attribute="description" hit={hit} />
The attribute description needs to be parsed. In the rest of my app i am using the libray
html-react-parser
I have tried this, but no luck.
const modifiedDescription = parse(hit.description);
<Highlight attribute="description" hit={{ ...hit, description: modifiedDescription }} />
It still output the HTML tags in the browser.
Does anyone know how to solve this?
Beta Was this translation helpful? Give feedback.
All reactions