'<' and '>' commands added. Experimental support for URLs added.

master
Sam Hunter 3 months ago
parent b1ab4479ed
commit 7ad33e10c2

@ -28,12 +28,13 @@ options:
- `z` - next screenful of headers
- `h` - redisplay headers
- `q` - quit
- `>` - increases text width by 4 characters (in `wrap` mode)
- `<` - decreases text width by 4 characters (in `wrap` mode)
- `:wrap`/`:nowrap` - toggle line wrapping
- `:pager`/`:nopager` - activate/deactivate external pager ("less" for now)
- `:md`/`:nomd` - toggle MarkDown formatting
- `g` - go back to the first page
- `G` - go to the oldest message / last page
- `/` - search in shlog titles
- `!command` - executes `command`
- accepts optional parameters:
- `{f}` - shlog filename

@ -3,6 +3,7 @@
# https://git.rawtext.club/samhunter/edlogxx
with_markdown = True
wrapwidth = 80
import glob
import os
@ -48,6 +49,8 @@ def display_help():
G - go to last post
/ - search in the titles
q - quit
> - increases text width by 4 characters (in `wrap` mode)
< - decreases text width by 4 characters (in `wrap` mode)
!command - execute `command`. Accepts optional parameters:
- {f} - shlog file
- {t} - shlog title
@ -164,19 +167,26 @@ def cat(shlog, wrap=False, internal_pager=True, md_format=False):
author = shlog[1][1]
if wrap == True:
margin = 4
textwidth=min(80, cols) - margin * 2
textwidth=min(wrapwidth, cols) - margin * 2
filler=" " * margin
else:
filler = ""
textwidth = cols
if os.access(file, os.R_OK):
if md_format == True:
lines = [];
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:
for line in f.readlines():
links += re.findall(link_re, line.rstrip())
lines += [line.rstrip()]
if len(links) > 0:
lines += [f' \n**Links**:\n']
lines += map( lambda x: "- " + x, links)
lines += [f' \n**Source**: *{file}*']
console.print(Markdown("\n".join(lines)))
else:
@ -386,6 +396,10 @@ try:
wrapped = True
elif cmd == ':nowrap':
wrapped = False
elif cmd == '>':
wrapwidth += 4
elif cmd == '<':
wrapwidth -= 4
elif cmd == ':pager':
internal = False
elif cmd == ':nopager':

@ -87,10 +87,6 @@ next screenful of headers
redisplay headers
.TP
.B
\fB/\fIterm\fP
search for \fIterm\fP in shlog titles
.TP
.B
\fBH\fP
reload and redisplay headers
.TP

Loading…
Cancel
Save