// markdown utility for replacing and swapping content detils
export function renderMarkdown(markdownText = '') {
const htmlText = markdownText
.replace(/^### (.*$)/gim, '
$1
')
.replace(/^## (.*$)/gim, '$1
')
.replace(/^# (.*$)/gim, '$1
')
.replace(/^\> (.*$)/gim, '$1
')
.replace(/\*\*(.*)\*\*/gim, '$1')
.replace(/\*(.*)\*/gim, '$1')
// .replace(/!\[(.*?)\]\((.*?)\)/gim, "
")
.replace(/\[(.*?)\]\((.*?)\)/gim, "$1")
.replace(/`(.*?)`/gim, '$1')
.replace(/\n$/gim, '
')
return htmlText.trim()
}
export function renderCommitMessage(msg: string) {
return renderMarkdown(msg).replace(
/\#([0-9]+)/g,
"#$1"
)
}
export const EXTERNAL_URL_RE = /^[a-z]+:/i
export const PATHNAME_PROTOCOL_RE = /^pathname:\/\//
export function isExternal(path: string): boolean {
return EXTERNAL_URL_RE.test(path)
}