valaxy-addon-git-log
Version:
Integrates git logs into your page of Valaxy site.
22 lines (19 loc) • 831 B
text/typescript
// https://github.com/vueuse/vueuse/blob/main/packages/.vitepress/theme/utils.ts
export function renderMarkdown(markdownText = '') {
const htmlText = markdownText
.replace(/^### (.*$)/gm, '<h3>$1</h3>')
.replace(/^## (.*$)/gm, '<h2>$1</h2>')
.replace(/^# (.*$)/gm, '<h1>$1</h1>')
.replace(/^> (.*$)/gm, '<blockquote>$1</blockquote>')
.replace(/\*\*(.*)\*\*/g, '<b>$1</b>')
.replace(/\*(.*)\*/g, '<i>$1</i>')
.replace(/!\[(.*?)\]\((.*?)\)/g, '<img alt=\'$1\' src=\'$2\' />')
.replace(/\[(.*?)\]\((.*?)\)/g, '<a href=\'$2\'>$1</a>')
.replace(/`(.*?)`/g, '<code>$1</code>')
.replace(/\n$/gm, '<br />')
return htmlText.trim()
}
export function renderCommitMessage(msg: string, repo: string) {
return renderMarkdown(msg)
.replace(/#(\d+)/g, `<a href=\'${repo}/issues/$1\'>#$1</a>`)
}