Skip to content
Snippets Groups Projects
Commit bde0cb09 authored by JBorrow's avatar JBorrow
Browse files

Updated renderer to use new versions as of py 3.10

parent 0d573dec
Branches
No related tags found
No related merge requests found
......@@ -23,7 +23,7 @@ import yaml
def open_meta(filename="about_meta.yaml", data_dir="../data"):
""" Read the meta file and return the associated data """
with open(f"{data_dir}/{filename}", "r") as handle:
return yaml.load(handle)
return yaml.safe_load(handle)
def compile_markdown(data, data_dir="../data"):
......@@ -50,6 +50,9 @@ class Parser(HTMLParser):
self.waiting_for_data = False
def handle_starttag(self, tag, attrs):
if len(attrs) == 0:
return
for attr in attrs:
if attr[0] == "id":
this_id = attr[1]
......
......@@ -44,7 +44,7 @@ def get_associated_data(template_names, data_dir="../data"):
# YAML Search
try:
with open(f"{data_dir}/{stub}.yaml", "r") as handle:
this_data = dict(yaml.load(handle), **this_data)
this_data = dict(yaml.safe_load(handle), **this_data)
except FileNotFoundError:
pass
......@@ -104,7 +104,7 @@ def global_variables(active, data_dir="../data"):
production of the processed navbar. """
with open("{}/global.yaml".format(data_dir), "r") as handle:
raw = yaml.load(handle) # We need to process the navbar.
raw = yaml.safe_load(handle) # We need to process the navbar.
return process_navbar(raw, active)
......
......@@ -32,7 +32,7 @@ except (OSError, ModuleNotFoundError) as e:
print("Pandoc not found on your system. Using mistune (python-only)")
import mistune
class IDRenderer(mistune.Renderer):
class IDRenderer(mistune.HTMLRenderer):
def header(self, text, level, raw=None):
text = "<h{} id={}>{}</h{}>".format(
level,
......@@ -43,8 +43,8 @@ except (OSError, ModuleNotFoundError) as e:
return text
renderer = IDRenderer()
markdown = mistune.Markdown(renderer=renderer)
renderer = IDRenderer(escape=False)
markdown = mistune.create_markdown(renderer=renderer)
def convert_text(input_text):
return markdown(input_text)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment