From 8a75d75d833f1628cd01f84d2f04824cc1ee8a76 Mon Sep 17 00:00:00 2001 From: zephyrkul Date: Sat, 19 Sep 2020 18:12:11 -0600 Subject: [PATCH] Add `quote()` function to chat formatting utilities (#4425) * add quote to chat_formatting * ... * jack's request --- redbot/core/utils/chat_formatting.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/redbot/core/utils/chat_formatting.py b/redbot/core/utils/chat_formatting.py index f4fff6435..e265d348c 100644 --- a/redbot/core/utils/chat_formatting.py +++ b/redbot/core/utils/chat_formatting.py @@ -1,5 +1,6 @@ import datetime import itertools +import textwrap from io import BytesIO from typing import Iterator, List, Optional, Sequence, SupportsInt, Union @@ -326,6 +327,23 @@ def underline(text: str, escape_formatting: bool = True) -> str: return "__{}__".format(text) +def quote(text: str) -> str: + """Quotes the given text. + + Parameters + ---------- + text : str + The text to be marked up. + + Returns + ------- + str + The marked up text. + + """ + return textwrap.indent(text, "> ", lambda l: True) + + def escape(text: str, *, mass_mentions: bool = False, formatting: bool = False) -> str: """Get text with all mass mentions or markdown escaped.