add remove Empty Line

This commit is contained in:
2021-01-08 16:12:23 +08:00
parent f823865045
commit da5ad656b0
2 changed files with 19 additions and 2 deletions

View File

@@ -27,7 +27,7 @@ from hashl import md5WithBase64
from enum import Enum from enum import Enum
from rsstempdict import rssMetaInfo, rssMetaList from rsstempdict import rssMetaInfo, rssMetaList
from random import randrange from random import randrange
from textc import textc from textc import textc, removeEmptyLine
from re import search, I from re import search, I
from rsschecker import RSSCheckerThread from rsschecker import RSSCheckerThread
from rsslist import getInlineKeyBoardForRSSList, InlineKeyBoardForRSSList, getInlineKeyBoardForRSSInList, getTextContentForRSSInList from rsslist import getInlineKeyBoardForRSSList, InlineKeyBoardForRSSList, getInlineKeyBoardForRSSInList, getTextContentForRSSInList
@@ -167,7 +167,7 @@ class main:
text.addtotext( text.addtotext(
f"""<a href="{content['link']}">{escape(content['link'])}</a>""") f"""<a href="{content['link']}">{escape(content['link'])}</a>""")
if config.show_content and 'description' in content and content['description'] is not None and content['description'] != '': if config.show_content and 'description' in content and content['description'] is not None and content['description'] != '':
text.addtotext(content['description']) text.addtotext(removeEmptyLine(content['description']))
def getListCount(content: dict, key: str): def getListCount(content: dict, key: str):
if key not in content or content[key] is None: if key not in content or content[key] is None:

View File

@@ -36,3 +36,20 @@ def timeToStr(t: int) -> str:
te = te + op + \ te = te + op + \
f'{int(abs(timezone)/3600):02}:{int(abs(timezone)%3600/60):02}' f'{int(abs(timezone)/3600):02}:{int(abs(timezone)%3600/60):02}'
return te return te
def removeEmptyLine(s: str) -> str:
l = s.splitlines(False)
r = []
for v in l:
if v != '':
r.append(v)
f = True
z = ''
for v in r:
if f:
f = False
z = v
else:
z = z + '\n' + v
return z