From 82585362dc0b393e95ad40643fbd5225e2ee593e Mon Sep 17 00:00:00 2001 From: Yuukiy <76897913+Yuukiy@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:17:08 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E8=BF=9B=E6=9B=B4=E6=96=B0=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E7=9A=84=E6=98=BE=E7=A4=BA=EF=BC=9A=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E6=97=A5=E5=BF=97=E5=BC=80=E5=A4=B4=E7=9A=84?= =?UTF-8?q?=E6=AE=B5=E8=90=BD=E5=B9=B6=E9=99=90=E5=88=B6=E5=88=86=E9=9A=94?= =?UTF-8?q?=E7=AC=A6=E6=9C=80=E5=A4=A7=E5=AE=BD=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/func.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/func.py b/core/func.py index 2ed86b48c..b551a2450 100644 --- a/core/func.py +++ b/core/func.py @@ -116,7 +116,8 @@ def print_header(title, info=[]): info_width = max([get_actual_width(i) for i in info]) else: info_width = 0 - display_width = max(title_width, info_width) + 6 + terminal_width = shutil.get_terminal_size().columns + display_width = min(max(title_width, info_width) + 6, terminal_width) print('=' * display_width) for line in title: print(align_center(line, display_width)) @@ -168,12 +169,17 @@ def print_header(title, info=[]): titles.append(release_url) # 提取changelog消息 try: - lines = data['body'].split('\r\n') + enable_msg_head = True + lines = data['body'].splitlines() changelog = [f'更新时间: {release_date}'] for line in lines: if line.startswith('## '): + enable_msg_head = False changelog.append(Style.BRIGHT + line[3:] + Style.RESET_ALL) elif line.startswith('- '): + enable_msg_head = False + changelog.append(line) + elif enable_msg_head: changelog.append(line) print_header(titles, changelog) except: