commit 426bd32214614d97c3ffaab43593c2ca8bdb8521 Author: NJL <23+njl@noreply.git.churchofmalware.org> Date: Fri Jun 26 17:42:45 2026 +0000 Add main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..3437ae1 --- /dev/null +++ b/main.py @@ -0,0 +1,31 @@ +import sys + +try: + sys.stdout.reconfigure(encoding="utf-8") + sys.stdin.reconfigure(encoding="utf-8") +except (AttributeError, ValueError): + pass + +RLE = "‫" +ALM = "؜" +PUNCTUATION = "!?.,;:…" + + +def transform(message): + trailing = "" + while message and message[-1] in PUNCTUATION: + trailing = message[-1] + trailing + message = message[:-1] + if "|" in message: + head, _, tail = message.partition("|") + body = head + RLE + trailing + RLE + RLE + tail.replace("|", RLE) + else: + body = message + RLE + trailing + RLE + RLE + return body + ALM + ALM + RLE + + +while True: + try: + print(transform(input("> "))) + except (KeyboardInterrupt, EOFError): + break