Skip to content

Commit

Permalink
fix metadata is kept between articles
Browse files Browse the repository at this point in the history
  • Loading branch information
mstingl committed Dec 12, 2024
1 parent 7990cc3 commit 5406534
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions md2weasypdf/printer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os
import re
import warnings
from copy import deepcopy
from dataclasses import dataclass, field
from datetime import date, datetime
from functools import cache
Expand Down Expand Up @@ -106,7 +107,7 @@ def _init_yaml(self):

article_template = self._get_template_env().from_string(md_template.content)

self.meta = {**md_template.metadata, **getattr(article, "metadata", {})}
self.meta |= md_template.metadata | getattr(article, "metadata", {})
self.content_md = article_template.render(article)

@property
Expand Down Expand Up @@ -335,7 +336,7 @@ def __init__(
raise ValueError("A title cannot be specified when not using bundle.")

def _load_article(self, source: Path):
return Article(source=source, template_loader_searchpaths=[self.input], meta=self.meta)
return Article(source=source, template_loader_searchpaths=[self.input], meta=deepcopy(self.meta))

def get_documents(self):
return [
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = md2weasypdf
version = 0.0.43
version = 0.0.44
author = Manuel Stingl
author_email = [email protected]
description = Print PDFs from Markdown Files using Weasyprint
Expand Down

0 comments on commit 5406534

Please sign in to comment.