From 24cfa48deaea3e34e396d1d2e7d5f0d40a0b31ae Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Sat, 12 Nov 2022 07:29:08 +0100 Subject: [PATCH] Change how toot is entered in editor This approach allows posting lines which start with a #. --- toot/utils.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/toot/utils.py b/toot/utils.py index 7053fe4..f1b0736 100644 --- a/toot/utils.py +++ b/toot/utils.py @@ -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()