Skip to content

Commit

Permalink
fix: fix raw header-includes
Browse files Browse the repository at this point in the history
  • Loading branch information
DCsunset committed Apr 11, 2021
1 parent 921e088 commit 3caa003
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pandoc_include.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,16 +154,16 @@ def action(elem, doc):
raw, extra_args=pandoc_options)

# Get metadata (Recursive header include)
new_metadata = pf.convert_text(raw, standalone=True, extra_args=pandoc_options).get_metadata()
new_metadata = pf.convert_text(raw, standalone=True, extra_args=pandoc_options).get_metadata(builtin=False)

else:
# Read header from yaml
new_metadata = yaml.safe_load(raw)
new_metadata = OrderedDict(new_metadata)
# Use pf to preserve all info
new_metadata = pf.convert_text(f"---\n{raw}\n---", standalone=True).get_metadata(builtin=False)

# Merge metadata
for key in new_metadata:
if not key in doc.get_metadata():
for key in new_metadata.content:
if not key in doc.metadata.content:
doc.metadata[key] = new_metadata[key]

# delete temp file (the file might have been deleted in subsequent executions)
Expand Down

0 comments on commit 3caa003

Please sign in to comment.