diff options
| author | 2020-07-20 02:31:56 +0200 | |
|---|---|---|
| committer | 2020-07-20 02:31:56 +0200 | |
| commit | cecd2c8e320a2a0ff0095cd1fa197552d43c6684 (patch) | |
| tree | de19c2d5ef232f80acd598327becd31cc440c5ba | |
| parent | Remove permalink from truncated markdown. (diff) | |
Simplify cutoff text.
"read more" seemed out of place with no permalink over it.
| -rw-r--r-- | bot/cogs/doc/parsing.py | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/bot/cogs/doc/parsing.py b/bot/cogs/doc/parsing.py index 3b79e0a93..994124e92 100644 --- a/bot/cogs/doc/parsing.py +++ b/bot/cogs/doc/parsing.py @@ -1,5 +1,6 @@ import logging import re +import string from typing import Callable, List, Optional, Tuple, Union from aiohttp import ClientSession @@ -96,8 +97,8 @@ def truncate_markdown(markdown: str, max_length: int) -> str: if description_cutoff == -1: # Search the shortened version for cutoff points in decreasing desirability, # cutoff at 1000 if none are found. - for string in (". ", ", ", ",", " "): - description_cutoff = shortened.rfind(string) + for cutoff_string in (". ", ", ", ",", " "): + description_cutoff = shortened.rfind(cutoff_string) if description_cutoff != -1: break else: @@ -108,7 +109,7 @@ def truncate_markdown(markdown: str, max_length: int) -> str: if markdown.count("```") % 2: codeblock_start = markdown.rfind('```py') markdown = markdown[:codeblock_start].rstrip() - markdown += "... read more" + markdown = markdown.rstrip(string.punctuation) + "..." return markdown |