import linkifyIt from "linkify-it";
const linkify = linkifyIt();
function linkifyContent(content: string) {
const matches = linkify.match(content),
result = [];
let last: number;
if (matches) {
last = 0;
matches.forEach(function (match) {
if (last < match.index) {
result.push(content.slice(last, match.index).replace(/\r?\n/g, "
"));
}
result.push('');
result.push(match.text);
result.push("");
last = match.lastIndex;
});
if (last < content.length) {
result.push(content.slice(last).replace(/\r?\n/g, "
"));
}
content = result.join("");
}
return content;
}
export default linkifyContent;