diff --git a/about.py b/about.py index db61e91053efd86ffa5c54f2f7c738dcbfaddd73..c5f8a03b4475f7646270115e9b7ce16dec7bb10c 100644 --- a/about.py +++ b/about.py @@ -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] diff --git a/compiler.py b/compiler.py index ad5d3e597923ec69a47787c942e777532c1280cd..c05b8c9ef4283cd73e1e8562089664fc60ccf2c1 100644 --- a/compiler.py +++ b/compiler.py @@ -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) diff --git a/mdcomp.py b/mdcomp.py index bc8cbc09170ae2f81a34706732d2f2d1afb4a97e..ab3ee792fbfdb0e711bda6b7def68ecdc109d5f7 100644 --- a/mdcomp.py +++ b/mdcomp.py @@ -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)