2021-06-07 14:01:15 +00:00
|
|
|
import React from "react";
|
|
|
|
import ReactMarkdown from "react-markdown";
|
|
|
|
import gfm from "remark-gfm";
|
|
|
|
|
|
|
|
if (!String.prototype.replaceAll) {
|
|
|
|
String.prototype.replaceAll = function(str, newStr){
|
|
|
|
|
|
|
|
// If a regex pattern
|
|
|
|
if (Object.prototype.toString.call(str).toLowerCase() === '[object regexp]') {
|
|
|
|
return this.replace(str, newStr);
|
|
|
|
}
|
|
|
|
|
|
|
|
// If a string
|
|
|
|
return this.replace(new RegExp(str, 'g'), newStr);
|
|
|
|
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2021-06-12 14:13:13 +00:00
|
|
|
export function DisplayAsMarkdown({markdowntext, className}){
|
2021-06-10 21:52:33 +00:00
|
|
|
//console.log(markdowntext)
|
2021-06-07 14:01:15 +00:00
|
|
|
markdowntext = markdowntext.replaceAll("\n", "\n\n")
|
|
|
|
return( <ReactMarkdown
|
|
|
|
plugins={[gfm]}
|
|
|
|
children={markdowntext}
|
2021-06-12 14:13:13 +00:00
|
|
|
className={className}
|
2021-06-07 14:01:15 +00:00
|
|
|
/>)
|
|
|
|
}
|