Skip to content

Commit

Permalink
chore: merge pull request #42 from AdrianDC/master
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbrignon authored Oct 28, 2024
2 parents de1099e + 1ce1d3b commit 62f72c5
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/configuration/generating-pdf-documents.md
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ There are five available options for managing cover pages:
- `all` (*default*): retains every cover page from all documents.
- `none`: removes every cover page from the aggregated document, resulting in a compilation that includes only the main content of each PDF.
- `limits`: retains the front cover of the first document and the back cover of the last document, while removing all other cover pages in between.
- `book`: retains the front cover of the first document and the back cover of the last document, while keeping only the front cover pages in between.
- `front`: preserves every front cover page from all documents but removes all back cover pages.
- `back`: preserves every back cover page from all documents but removes all front cover pages.

Expand Down
7 changes: 7 additions & 0 deletions mkdocs_exporter/formats/pdf/aggregator.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ def set_pages(self, pages: list[Page]) -> Aggregator:
self._skip(page, ['front'])
else:
self._skip(page, ['front', 'back'])
elif covers == 'book':
if len(self.pages) == 1:
pass
elif index == 0:
self._skip(page, ['back'])
elif index < (len(self.pages) - 1):
self._skip(page, ['back'])

return self

Expand Down
2 changes: 1 addition & 1 deletion mkdocs_exporter/formats/pdf/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class AggregatorConfig(BaseConfig):
metadata = c.Type(dict, default={})
"""Some metadata to append to the PDF document."""

covers = c.Choice(['all', 'none', 'limits', 'front', 'back'], default='all')
covers = c.Choice(['all', 'none', 'limits', 'book', 'front', 'back'], default='all')
"""The behavior of cover pages."""


Expand Down

0 comments on commit 62f72c5

Please sign in to comment.