Skip to content

Commit

Permalink
Fixed a bug with number-only page titles. #67
Browse files Browse the repository at this point in the history
  • Loading branch information
orzih committed Jul 3, 2021
1 parent fd7096d commit 35dedee
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion mkdocs_with_pdf/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ def shift_heading(elem, page):

page_path = self._page_path_for_id(page)
h1 = soup.new_tag('h1', id=f'{page_path}')
h1.append(page.title)
h1.append(str(page.title))
elem.insert(0, h1)
return elem

Expand Down
3 changes: 2 additions & 1 deletion mkdocs_with_pdf/utils/section.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ def _section_slug(section) -> str:
if slug:
return slug

title = section.title if len(section.title) else str(uuid4)
title = str(section.title).strip()
title = title if title else str(uuid4)
slug = b32encode(title.encode('utf-8')).rstrip(b'=').decode()
setattr(section, 'pdf_slug', slug)

Expand Down

0 comments on commit 35dedee

Please sign in to comment.