added URL support
This commit is contained in:
@@ -84,6 +84,20 @@ function applyInline(text) {
|
||||
)}" target="_blank" rel="noreferrer">${label}</a>`;
|
||||
});
|
||||
|
||||
output = output.replace(/https?:\/\/[^\s<]+/g, (match) => {
|
||||
let url = match;
|
||||
let suffix = "";
|
||||
while (/[),.;!?]$/.test(url)) {
|
||||
suffix = url.slice(-1) + suffix;
|
||||
url = url.slice(0, -1);
|
||||
}
|
||||
const safeUrl = sanitizeUrl(url);
|
||||
if (!safeUrl) return match;
|
||||
return `<a href="${escapeAttribute(
|
||||
safeUrl
|
||||
)}" target="_blank" rel="noreferrer">${safeUrl}</a>${suffix}`;
|
||||
});
|
||||
|
||||
output = output.replace(/\*\*([^*]+)\*\*/g, "<strong>$1</strong>");
|
||||
output = output.replace(/\*([^*]+)\*/g, "<em>$1</em>");
|
||||
output = output.replace(/_([^_]+)_/g, "<em>$1</em>");
|
||||
|
||||
Reference in New Issue
Block a user