diff options
| author | 2020-06-27 15:48:28 +0200 | |
|---|---|---|
| committer | 2020-06-27 15:48:28 +0200 | |
| commit | ff3afe58548a8f1ed675c1933545e481e99bfc78 (patch) | |
| tree | ca8555c380f778cdf4cddf0686eb374fdaa594da | |
| parent | Redesign `find_all_text_until_tag` to search through all direct children. (diff) | |
Only include one newline for `p` tags in `li` elements.
| -rw-r--r-- | bot/cogs/doc.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py index e4b54f0a5..c1e8cebcf 100644 --- a/bot/cogs/doc.py +++ b/bot/cogs/doc.py @@ -124,6 +124,13 @@ class DocMarkdownConverter(MarkdownConverter): el["href"] = urljoin(self.page_url, el["href"]) return super().convert_a(el, text) + def convert_p(self, el: PageElement, text: str) -> str: + """Include only one newline instead of two when the parent is a li tag.""" + parent = el.parent + if parent is not None and parent.name == "li": + return f"{text}\n" + return super().convert_p(el, text) + def markdownify(html: str, *, url: str = "") -> str: """Create a DocMarkdownConverter object from the input html.""" |