fix: remove problematic Markdown optimization (via #5520)
This commit is contained in:
@@ -15,22 +15,11 @@ DomPurify.addHook("beforeSanitizeElements", function (current, ) {
|
|||||||
return current
|
return current
|
||||||
})
|
})
|
||||||
|
|
||||||
// eslint-disable-next-line no-useless-escape
|
|
||||||
const isPlainText = (str) => /^[A-Z\s0-9!?\.]+$/gi.test(str)
|
|
||||||
|
|
||||||
function Markdown({ source, className = "" }) {
|
function Markdown({ source, className = "" }) {
|
||||||
if (typeof source !== "string") {
|
if (typeof source !== "string") {
|
||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
if(isPlainText(source)) {
|
|
||||||
// If the source text is not Markdown,
|
|
||||||
// let's save some time and just render it.
|
|
||||||
return <div className="markdown">
|
|
||||||
{source}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
|
|
||||||
const md = new Remarkable({
|
const md = new Remarkable({
|
||||||
html: true,
|
html: true,
|
||||||
typographer: true,
|
typographer: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user