Skip to content

Commit

Permalink
fix: explicit encodings when using open
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienbrignon committed May 27, 2023
1 parent 9852a4e commit 0474b0f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions mkdocs_exporter/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def on_post_build(self, **kwargs) -> None:
for file in self.files:
css = None

with open(file.abs_dest_path, 'r') as reader:
with open(file.abs_dest_path, 'r', encoding='utf-8') as reader:
css = self.theme.stylesheet(reader.read())
with open(file.abs_dest_path, 'w+') as writer:
with open(file.abs_dest_path, 'w+', encoding='utf-8') as writer:
writer.write(css)
4 changes: 2 additions & 2 deletions mkdocs_exporter/plugins/pdf/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,10 @@ def on_page_markdown(self, markdown: str, page: Page, config: Config, **kwargs)
covers = {**self.config.covers, **{k: os.path.join(os.path.dirname(config['config_file_path']), v) for k, v in page.meta.get('covers', {}).items()}}

if covers.get('front'):
with open(covers['front'], 'r') as file:
with open(covers['front'], 'r', encoding='utf-8') as file:
content = self.renderer.cover(file.read()) + content
if covers.get('back'):
with open(covers['back'], 'r') as file:
with open(covers['back'], 'r', encoding='utf-8') as file:
content = content + self.renderer.cover(file.read())

for path in [path for path in covers.values() if path is not None]:
Expand Down
4 changes: 2 additions & 2 deletions mkdocs_exporter/plugins/pdf/renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ async def render(self, page: Page) -> bytes:
page.theme.preprocess(preprocessor)

for stylesheet in self.stylesheets:
with open(stylesheet, 'r') as file:
with open(stylesheet, 'r', encoding='utf-8') as file:
preprocessor.stylesheet(file.read())
for script in self.scripts:
with open(script, 'r') as file:
with open(script, 'r', encoding='utf-8') as file:
preprocessor.script(file.read())

preprocessor.script(importlib_resources.files(js).joinpath('pagedjs.min.js').read_text())
Expand Down

0 comments on commit 0474b0f

Please sign in to comment.