diff options
| author | 2019-11-02 17:26:50 +0100 | |
|---|---|---|
| committer | 2019-11-02 17:26:50 +0100 | |
| commit | efe592cc0420f325ab266afc822b8d4b8135d467 (patch) | |
| tree | 2b1ffdf157feef469b5a2e7433ee48c6fed48df7 | |
| parent | Grammar check comment (diff) | |
Do not cut off description in code blocks
| -rw-r--r-- | bot/cogs/doc.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py index 8b81b3053..4a095fa51 100644 --- a/bot/cogs/doc.py +++ b/bot/cogs/doc.py @@ -284,7 +284,13 @@ class Doc(commands.Cog): if len(description) > 1000: shortened = description[:1000] last_paragraph_end = shortened.rfind('\n\n') - description = description[:last_paragraph_end] + f"... [read more]({permalink})" + description = description[:last_paragraph_end] + + # If there is an incomplete code block, cut it out + if description.count("```") % 2: + codeblock_start = description.rfind('```py') + description = description[:codeblock_start].rstrip() + description += f"... [read more]({permalink})" description = WHITESPACE_AFTER_NEWLINES_RE.sub('', description) |