Skip to content

Commit

Permalink
Merge pull request #178 from anthonydillon/strip-headings-tutorials
Browse files Browse the repository at this point in the history
Strip heading titles for tutorials
  • Loading branch information
anthonydillon authored Oct 30, 2023
2 parents 2b1475f + 78b7611 commit 66e2d74
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions canonicalwebteam/discourse/parsers/tutorials.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def _get_sections(self, soup):

for heading in headings:
section = {}
section_soup = self._get_section(soup, heading.text)
heading_text = heading.text.strip()
section_soup = self._get_section(soup, heading_text)
first_child = section_soup.find() if section_soup else None

if first_child and first_child.text.startswith("Duration"):
Expand All @@ -72,11 +73,11 @@ def _get_sections(self, soup):

first_child.extract()

section["title"] = heading.text
section["title"] = heading_text
section["content"] = str(section_soup)

heading_pieces = filter(
lambda s: s.isalnum() or s.isspace(), heading.text.lower()
lambda s: s.isalnum() or s.isspace(), heading_text.lower()
)
section["slug"] = "".join(heading_pieces).replace(" ", "-")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

setup(
name="canonicalwebteam.discourse",
version="5.4.4",
version="5.4.5",
author="Canonical webteam",
author_email="[email protected]",
url="https://github.com/canonical/canonicalwebteam.discourse",
Expand Down

0 comments on commit 66e2d74

Please sign in to comment.