diff options
author | 2021-03-05 01:32:06 +0100 | |
---|---|---|
committer | 2021-03-05 02:46:41 +0100 | |
commit | c2c0dc2a8caced134422c005d010e7dd10cf7466 (patch) | |
tree | b266fcb8c3295fbe14d4116efb7476777c6abd02 | |
parent | Remove placeholder in shorten call (diff) |
Account for ellipses when determining the truncation description index
-rw-r--r-- | bot/exts/info/doc/_parsing.py | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/bot/exts/info/doc/_parsing.py b/bot/exts/info/doc/_parsing.py index b1b09ccc7..43e78ddca 100644 --- a/bot/exts/info/doc/_parsing.py +++ b/bot/exts/info/doc/_parsing.py @@ -170,14 +170,14 @@ def _get_truncated_description( if not markdown_element_ends: return "" - # Determine the "hard" truncation index. + # Determine the "hard" truncation index. Account for the ellipsis placeholder for the max length. newline_truncate_index = find_nth_occurrence(result, "\n", max_lines) - if newline_truncate_index is not None and newline_truncate_index < _MAX_DESCRIPTION_LENGTH: + if newline_truncate_index is not None and newline_truncate_index < _MAX_DESCRIPTION_LENGTH - 3: # Truncate based on maximum lines if there are more than the maximum number of lines. truncate_index = newline_truncate_index else: # There are less than the maximum number of lines; truncate based on the max char length. - truncate_index = _MAX_DESCRIPTION_LENGTH + truncate_index = _MAX_DESCRIPTION_LENGTH - 3 # Nothing needs to be truncated if the last element ends before the truncation index. if truncate_index >= markdown_element_ends[-1]: |