Skip to content

Commit

Permalink
Bump markdownify from 0.13.1 to 0.14.1 (#3205)
Browse files Browse the repository at this point in the history
* 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]>
  • Loading branch information
3 people authored Jan 1, 2025
2 parents 378c2ed + 4fedcef commit 2246207
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion bot/exts/info/doc/_markdown.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def convert_li(self, el: PageElement, text: str, convert_as_inline: bool) -> str
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
Expand Down
2 changes: 1 addition & 1 deletion bot/exts/info/doc/_parsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
8 changes: 4 additions & 4 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
18 changes: 18 additions & 0 deletions tests/bot/exts/info/doc/test_parsing.py
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -87,3 +89,19 @@ def _run_tests(self, test_cases: tuple[tuple[str, str], ...]):
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)

0 comments on commit 2246207

Please sign in to comment.