Links added to non-MD version as well.

master
Sam Hunter 3 months ago
parent 7ad33e10c2
commit 95c8c5661e

@ -173,11 +173,10 @@ def cat(shlog, wrap=False, internal_pager=True, md_format=False):
filler = ""
textwidth = cols
if os.access(file, os.R_OK):
link_re = r'(?:https?|gemini|spartan|file|ftp|gopher)://[^ \])]+'
links = []
if md_format == True:
lines = []
#XXX
link_re = r'(?:https?|gemini|spartan|file|ftp|gopher)://[^ \])]+'
links = []
lines += ["-" * 6 ] # post separator
lines += [f'**Title: {title}** \n**Author: {author}** \n**Date: {date}** \n']
with open(shlog[1][0]) as f:
@ -195,6 +194,7 @@ def cat(shlog, wrap=False, internal_pager=True, md_format=False):
with open(shlog[1][0]) as f:
for line in f.readlines():
line = line.rstrip()
links += re.findall(link_re, line)
if wrap==True:
lines = tw.fill(line,
width=textwidth,
@ -209,6 +209,10 @@ def cat(shlog, wrap=False, internal_pager=True, md_format=False):
print(f'\x1b[3m{line}\x1b[0m')
else:
print(line)
if len(links) > 0:
print(f'\n{filler}**Links**:')
for link in links:
print(f'{filler}\t{link}')
print(f'\n\n{filler}Source:\x1b[3m{file}\x1b[0m\n')
else:
if md_format == True:
@ -345,7 +349,6 @@ try:
else:
print("At the newest post.")
elif cmd[0] in '/':
#XXX
start = 0
end = height
pointer = start

Loading…
Cancel
Save