replace <> in code el
This commit is contained in:
2
dist/chrome/static/js/content.js
vendored
2
dist/chrome/static/js/content.js
vendored
File diff suppressed because one or more lines are too long
2
dist/edge/static/js/content.js
vendored
2
dist/edge/static/js/content.js
vendored
File diff suppressed because one or more lines are too long
2
dist/firefox/static/js/content.js
vendored
2
dist/firefox/static/js/content.js
vendored
File diff suppressed because one or more lines are too long
@@ -7,6 +7,7 @@ import {
|
|||||||
OPT_STYLE_WAVYLINE,
|
OPT_STYLE_WAVYLINE,
|
||||||
OPT_STYLE_FUZZY,
|
OPT_STYLE_FUZZY,
|
||||||
OPT_STYLE_HIGHTLIGHT,
|
OPT_STYLE_HIGHTLIGHT,
|
||||||
|
OPT_TRANS_OPENAI,
|
||||||
} from "../../config";
|
} from "../../config";
|
||||||
import { useTranslate } from "../../hooks/Translate";
|
import { useTranslate } from "../../hooks/Translate";
|
||||||
|
|
||||||
@@ -76,12 +77,30 @@ export default function Content({ q, rule }) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{q.length > 40 ? <br /> : " "}
|
{q.length > 40 ? <br /> : " "}
|
||||||
<span
|
{rule.translator === OPT_TRANS_OPENAI ? (
|
||||||
style={style}
|
<span
|
||||||
onMouseEnter={handleMouseEnter}
|
style={style}
|
||||||
onMouseLeave={handleMouseLeave}
|
onMouseEnter={handleMouseEnter}
|
||||||
dangerouslySetInnerHTML={{ __html: text }}
|
onMouseLeave={handleMouseLeave}
|
||||||
/>
|
>
|
||||||
|
{text}
|
||||||
|
</span>
|
||||||
|
) : (
|
||||||
|
<span
|
||||||
|
style={style}
|
||||||
|
onMouseEnter={handleMouseEnter}
|
||||||
|
onMouseLeave={handleMouseLeave}
|
||||||
|
dangerouslySetInnerHTML={{
|
||||||
|
__html: text.replace(
|
||||||
|
/<code>(.*?)<\/code>/gi,
|
||||||
|
(_match, p1) =>
|
||||||
|
`<code>${p1
|
||||||
|
.replace(/</g, "<")
|
||||||
|
.replace(/>/g, ">")}</code>`
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user