aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2020-06-27 15:48:28 +0200
committerGravatar Numerlor <[email protected]>2020-06-27 15:48:28 +0200
commitff3afe58548a8f1ed675c1933545e481e99bfc78 (patch)
treeca8555c380f778cdf4cddf0686eb374fdaa594da
parentRedesign `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.py7
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."""