1
0
mirror of https://github.com/ihabunek/toot.git synced 2024-11-03 04:17:21 -05:00

Change how toot is entered in editor

This approach allows posting lines which start with a #.
This commit is contained in:
Ivan Habunek 2022-11-12 07:29:08 +01:00
parent 5c2f9dcf7c
commit 24cfa48dea
No known key found for this signature in database
GPG Key ID: F5F0623FF5EBCB3D

View File

@ -92,9 +92,13 @@ def multiline_input():
return "\n".join(lines).strip()
EDITOR_INPUT_INSTRUCTIONS = """
# Please enter your toot. Lines starting with '#' will be ignored, and an empty
# message aborts the post.
EDITOR_DIVIDER = "------------------------ >8 ------------------------"
EDITOR_INPUT_INSTRUCTIONS = f"""
{EDITOR_DIVIDER}
Do not modify or remove the line above.
Enter your toot above it.
Everything below it will be ignored.
"""
@ -111,6 +115,4 @@ def editor_input(editor, initial_text):
f.seek(0)
text = f.read().decode()
lines = text.strip().splitlines()
lines = (l for l in lines if not l.startswith("#"))
return "\n".join(lines)
return text.split(EDITOR_DIVIDER)[0].strip()