aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar ChrisJL <[email protected]>2025-01-01 13:46:43 +0000
committerGravatar GitHub <[email protected]>2025-01-01 13:46:43 +0000
commit2246207c5e8b439b1aaee216cef672b530e8bfa3 (patch)
treeacb1e9fa15d235a9c943f2803c2a8f43ea249211
parentBump ruff from 0.8.0 to 0.8.4 (#3220) (diff)
parentFix rendering of markdown headers in docs (diff)
Bump markdownify from 0.13.1 to 0.14.1 (#3205)
* Bump markdownify from 0.13.1 to 0.14.1 Bumps [markdownify](https://github.com/matthewwithanm/python-markdownify) from 0.13.1 to 0.14.1. - [Release notes](https://github.com/matthewwithanm/python-markdownify/releases) - [Commits](https://github.com/matthewwithanm/python-markdownify/compare/0.13.1...0.14.1) --- updated-dependencies: - dependency-name: markdownify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <[email protected]> * Remove surrounding whitespace from doc description markdown * Fix rendering of markdown headers in docs --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: wookie184 <[email protected]>
-rw-r--r--bot/exts/info/doc/_markdown.py2
-rw-r--r--bot/exts/info/doc/_parsing.py2
-rw-r--r--poetry.lock8
-rw-r--r--pyproject.toml2
-rw-r--r--tests/bot/exts/info/doc/test_parsing.py18
5 files changed, 25 insertions, 7 deletions
diff --git a/bot/exts/info/doc/_markdown.py b/bot/exts/info/doc/_markdown.py
index f3d769070..a030903ed 100644
--- a/bot/exts/info/doc/_markdown.py
+++ b/bot/exts/info/doc/_markdown.py
@@ -31,7 +31,7 @@ class DocMarkdownConverter(markdownify.MarkdownConverter):
bullet = bullets[depth % len(bullets)]
return f"{bullet} {text}\n"
- def convert_hn(self, _n: int, el: PageElement, text: str, convert_as_inline: bool) -> str:
+ def _convert_hn(self, _n: int, el: PageElement, text: str, convert_as_inline: bool) -> str:
"""Convert h tags to bold text with ** instead of adding #."""
if convert_as_inline:
return text
diff --git a/bot/exts/info/doc/_parsing.py b/bot/exts/info/doc/_parsing.py
index dd2d6496c..bc5a5bd31 100644
--- a/bot/exts/info/doc/_parsing.py
+++ b/bot/exts/info/doc/_parsing.py
@@ -186,7 +186,7 @@ def _get_truncated_description(
# Nothing needs to be truncated if the last element ends before the truncation index.
if truncate_index >= markdown_element_ends[-1]:
- return result
+ return result.strip(string.whitespace)
# Determine the actual truncation index.
possible_truncation_indices = [cut for cut in markdown_element_ends if cut < truncate_index]
diff --git a/poetry.lock b/poetry.lock
index 0d3999e9a..d02fcd134 100644
--- a/poetry.lock
+++ b/poetry.lock
@@ -1151,13 +1151,13 @@ source = ["Cython (>=3.0.11)"]
[[package]]
name = "markdownify"
-version = "0.13.1"
+version = "0.14.1"
description = "Convert HTML to markdown."
optional = false
python-versions = "*"
files = [
- {file = "markdownify-0.13.1-py3-none-any.whl", hash = "sha256:1d181d43d20902bcc69d7be85b5316ed174d0dda72ff56e14ae4c95a4a407d22"},
- {file = "markdownify-0.13.1.tar.gz", hash = "sha256:ab257f9e6bd4075118828a28c9d02f8a4bfeb7421f558834aa79b2dfeb32a098"},
+ {file = "markdownify-0.14.1-py3-none-any.whl", hash = "sha256:4c46a6c0c12c6005ddcd49b45a5a890398b002ef51380cd319db62df5e09bc2a"},
+ {file = "markdownify-0.14.1.tar.gz", hash = "sha256:a62a7a216947ed0b8dafb95b99b2ef4a0edd1e18d5653c656f68f03db2bfb2f1"},
]
[package.dependencies]
@@ -2611,4 +2611,4 @@ propcache = ">=0.2.0"
[metadata]
lock-version = "2.0"
python-versions = "3.12.*"
-content-hash = "7a98308ec84411b335b74cc6c990e28dc18b7e98f905bde1eb4e4713dbd11173"
+content-hash = "d42ce38dc07698ca242a30f7f2836587a8965b07f707220b0b8bda9d11319305"
diff --git a/pyproject.toml b/pyproject.toml
index b26d5eb5c..fa48451a7 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -20,7 +20,7 @@ deepdiff = "7.0.1"
emoji = "2.14.0"
feedparser = "6.0.11"
lxml = "5.3.0"
-markdownify = "0.13.1"
+markdownify = "0.14.1"
python-dateutil = "2.9.0.post0"
python-frontmatter = "1.1.0"
rapidfuzz = "3.10.1"
diff --git a/tests/bot/exts/info/doc/test_parsing.py b/tests/bot/exts/info/doc/test_parsing.py
index d2105a53c..7136fc32c 100644
--- a/tests/bot/exts/info/doc/test_parsing.py
+++ b/tests/bot/exts/info/doc/test_parsing.py
@@ -1,5 +1,7 @@
from unittest import TestCase
+from bs4 import BeautifulSoup
+
from bot.exts.info.doc import _parsing as parsing
from bot.exts.info.doc._markdown import DocMarkdownConverter
@@ -87,3 +89,19 @@ class MarkdownConverterTest(TestCase):
with self.subTest(input_string=input_string):
d = DocMarkdownConverter(page_url="https://example.com")
self.assertEqual(d.convert(input_string), expected_output)
+
+
+class MarkdownCreationTest(TestCase):
+ def test_surrounding_whitespace(self):
+ test_cases = (
+ ("<p>Hello World</p>", "Hello World"),
+ ("<p>Hello</p><p>World</p>", "Hello\n\nWorld"),
+ ("<h1>Title</h1>", "**Title**")
+ )
+ self._run_tests(test_cases)
+
+ def _run_tests(self, test_cases: tuple[tuple[str, str], ...]):
+ for input_string, expected_output in test_cases:
+ with self.subTest(input_string=input_string):
+ tags = BeautifulSoup(input_string, "html.parser")
+ self.assertEqual(parsing._create_markdown(None, tags, "https://example.com"), expected_output)