Skip to content

Commit 2246207

Browse files
ChrisLoveringdependabot[bot]wookie184
authored
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](matthewwithanm/python-markdownify@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]>
2 parents 378c2ed + 4fedcef commit 2246207

File tree

5 files changed

+25
-7
lines changed

5 files changed

+25
-7
lines changed

bot/exts/info/doc/_markdown.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ def convert_li(self, el: PageElement, text: str, convert_as_inline: bool) -> str
3131
bullet = bullets[depth % len(bullets)]
3232
return f"{bullet} {text}\n"
3333

34-
def convert_hn(self, _n: int, el: PageElement, text: str, convert_as_inline: bool) -> str:
34+
def _convert_hn(self, _n: int, el: PageElement, text: str, convert_as_inline: bool) -> str:
3535
"""Convert h tags to bold text with ** instead of adding #."""
3636
if convert_as_inline:
3737
return text

bot/exts/info/doc/_parsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ def _get_truncated_description(
186186

187187
# Nothing needs to be truncated if the last element ends before the truncation index.
188188
if truncate_index >= markdown_element_ends[-1]:
189-
return result
189+
return result.strip(string.whitespace)
190190

191191
# Determine the actual truncation index.
192192
possible_truncation_indices = [cut for cut in markdown_element_ends if cut < truncate_index]

poetry.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ deepdiff = "7.0.1"
2020
emoji = "2.14.0"
2121
feedparser = "6.0.11"
2222
lxml = "5.3.0"
23-
markdownify = "0.13.1"
23+
markdownify = "0.14.1"
2424
python-dateutil = "2.9.0.post0"
2525
python-frontmatter = "1.1.0"
2626
rapidfuzz = "3.10.1"

tests/bot/exts/info/doc/test_parsing.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from unittest import TestCase
22

3+
from bs4 import BeautifulSoup
4+
35
from bot.exts.info.doc import _parsing as parsing
46
from bot.exts.info.doc._markdown import DocMarkdownConverter
57

@@ -87,3 +89,19 @@ def _run_tests(self, test_cases: tuple[tuple[str, str], ...]):
8789
with self.subTest(input_string=input_string):
8890
d = DocMarkdownConverter(page_url="https://example.com")
8991
self.assertEqual(d.convert(input_string), expected_output)
92+
93+
94+
class MarkdownCreationTest(TestCase):
95+
def test_surrounding_whitespace(self):
96+
test_cases = (
97+
("<p>Hello World</p>", "Hello World"),
98+
("<p>Hello</p><p>World</p>", "Hello\n\nWorld"),
99+
("<h1>Title</h1>", "**Title**")
100+
)
101+
self._run_tests(test_cases)
102+
103+
def _run_tests(self, test_cases: tuple[tuple[str, str], ...]):
104+
for input_string, expected_output in test_cases:
105+
with self.subTest(input_string=input_string):
106+
tags = BeautifulSoup(input_string, "html.parser")
107+
self.assertEqual(parsing._create_markdown(None, tags, "https://example.com"), expected_output)

0 commit comments

Comments
 (0)