From bcf2def56f10f9a21b130e12c75954305100fe91 Mon Sep 17 00:00:00 2001 From: bobloy Date: Tue, 8 Dec 2020 13:06:58 -0500 Subject: [PATCH] Lets use multiline instead of being dumb --- cogguide/cogguide.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/cogguide/cogguide.py b/cogguide/cogguide.py index 94dd46f..7023488 100644 --- a/cogguide/cogguide.py +++ b/cogguide/cogguide.py @@ -16,7 +16,19 @@ LINK_PATTERN = re.compile(r"\[(.+)]\s?\((https?:\/\/[\w\d.\/?=#-@]+)\)") BOTNAME_PATTERN = re.compile(r"\[botname]") -WARNING_PATTERN = re.compile(r"Warning: (.*)") + +# Adding more as necessary. +# Options: +# [X] attention +# [ ] caution +# [ ] danger +# [ ] error +# [X] hint +# [X] important +# [X] note +# [X] tip +# [X] warning +NOTICE_PATTERNS = re.compile(r"^(Warning|Note|Attention|Hint|Important|Tip): (.*)", re.MULTILINE) def get_parent_tree(command: commands.Command): @@ -67,12 +79,11 @@ def format_text(text): # We shouldn't get here: return s - def replace_warning(m: re.Match) -> str: - s = m.group(1) - return f".. warning:: {s}\n" + def replace_notice(m: re.Match) -> str: + return f".. {m.group(1)}:: {m.group(2)}\n" out = BOTNAME_PATTERN.sub(replace_botname, text) - out = WARNING_PATTERN.sub(replace_warning, out) + out = NOTICE_PATTERNS.sub(replace_notice, out) return out