remarkablemark / html-react-parser

📝 HTML to React parser.

Home Page:https://b.remarkabl.org/html-react-parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Curly Brace Symbol Doesn't Show

saraOrkide opened this issue · comments

commented

I want to parse the mml, but when it comes to the mfenced tag, the value of the open attribute changes from "}" to "true".
I used the latest version and set sanitize for it, but it didn't work
example mml:
<div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> متناظر با هر عبارت، یک مجموعه و متناظر با هر مجموعه، یک عبارت بنویسید و تعداد عضوهای هر مجموعه را تعیین کنید. </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> الف) <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mi>A</mi><mo>=</mo><mfenced open="{" close="}" separators="|"><mrow><mn>1,8</mn><mo>,</mo><mn>27,64,125</mn></mrow></mfenced></math></span> </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> ب) <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mi>C</mi><mo>=</mo><mfenced open="{" close="}" separators="|"><mrow><mn>10</mn></mrow></mfenced></math></span> </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> ج) عددهای طبیعی مضرب <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>5</mn></math></span> و کوچکتر از <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>100</mn></math></span> </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> د) عددهای طبیعی بزرگتر از <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>4</mn></math></span> و کوچکتر از <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>5</mn></math></span> </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> هـ) عددهای صحیح منفی که بین <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>4</mn></math></span> و <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mn>7</mn></math></span> قرار دارد. </span></div><div class='chistaItem' style='text-align:right;/*MARK-BY-CHISTA-PARSER*/direction:rtl;/*MARK-BY-CHISTA-PARSER*/'><span class='chistaText'> و) عددهای اول دو رقمی که مضرب <span class="chistaFormula"><math xmlns="http://www.w3.org/1998/Math/MathML" display="inline-block"><mi>r</mi></math></span> باشد. </span></div>

Generally, it sets the value of the open attribute to true

commented

@saraOrkide can you provide a reproducible example using CodeSandbox JavaScript or CodeSandbox TypeScript?

commented

@saraOrkide I don't see your changes. Can you fork and save a new CodeSandbox?

commented

@saraOrkide I don't see your changes. Can you fork and save a new CodeSandbox?

Oh sorry, forgot to save
see now

commented

@saraOrkide can you share the new link that was created after save?

commented

@saraOrkide can you share the new link that was created after save?

https://codesandbox.io/s/laughing-dhawan-sq5p28?file=/src/index.js

commented

I reproduced your issue and it's caused by the open prop being converted to a boolean value:

Screen Shot 2023-10-13 at 1 39 44 PM

I think the fix will need to be done in https://github.com/remarkablemark/react-dom-core/tree/master/packages/react-property

Actually this is a React bug, I can reproduce in https://codesandbox.io/s/html-react-parser-1080-23nhj2

commented

Ok, I know, why does it convert it to boolean?
How can I solve the problem?
with react-property?!!
Can you please tell me with the sample code that I sent

commented

@saraOrkide unfortunately there is nothing I can do on my side since this is a React bug. See reproduced demo

My recommendation is to stick with dangerouslySetInnerHTML

commented

My recommendation is to stick with dangerouslySetInnerHTML

My problem is that I want to replace a tag, so I wanted to use html-react-parser

commented

You can use dangerouslySetInnerHTML with html-react-parser

commented

You can use dangerouslySetInnerHTML with html-react-parser

Can you tell me how?