From e0c5923dcb0bebe7e0085c4d01fd29e8ca8a9d27 Mon Sep 17 00:00:00 2001 From: Meekdai Date: Tue, 28 May 2024 17:16:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A05=E7=A7=8Dalerts=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 具体可参考下面的链接 https://docs.github.com/zh/get-started/writing-on-github/getting-started-with-writing-and-formatting-on-github/basic-writing-and-formatting-syntax#alerts --- Gmeek.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/Gmeek.py b/Gmeek.py index a9e75e4..1e22b0b 100644 --- a/Gmeek.py +++ b/Gmeek.py @@ -137,6 +137,26 @@ class GMEEK(): post_body=re.sub(r'','',post_body) post_body=re.sub(r'','',post_body) issue["script"]=issue["script"]+'' + + if '

' in post_body: + issue["style"]=issue["style"]+'.markdown-alert{padding:0.5rem 1rem;margin-bottom:1rem;border-left:.25em solid var(--borderColor-default,var(--color-border-default));}.markdown-alert .markdown-alert-title {display:flex;font-weight:var(--base-text-weight-medium,500);align-items:center;line-height:1;}.markdown-alert>:first-child {margin-top:0;}.markdown-alert>:last-child {margin-bottom:0;}' + alerts = { + 'note': 'accent', + 'tip': 'success', + 'important': 'done', + 'warning': 'attention', + 'caution': 'danger' + } + + for alert, style in alerts.items(): + if f'markdown-alert-{alert}' in post_body: + issue["style"] += ( + f'.markdown-alert.markdown-alert-{alert} {{' + f'border-left-color:var(--borderColor-{style}-emphasis, var(--color-{style}-emphasis));' + f'background-color:var(--color-{style}-subtle);}}' + f'.markdown-alert.markdown-alert-{alert} .markdown-alert-title {{' + f'color: var(--fgColor-{style},var(--color-{style}-fg));}}' + ) postBase["postTitle"]=issue["postTitle"] postBase["postUrl"]=self.blogBase["homeUrl"]+"/"+issue["postUrl"]