Skip to content

Commit

Permalink
👌 IMPROVE: Fail gracefully on non-dict front-matter (#409)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisjsewell authored Aug 6, 2021
1 parent 5fd4c51 commit 61f1154
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion myst_parser/docutils_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,12 @@ def render_front_matter(self, token: SyntaxTreeNode) -> None:
if not isinstance(token.content, dict):
try:
data = yaml.safe_load(token.content)
except (yaml.parser.ParserError, yaml.scanner.ScannerError) as error:
assert isinstance(data, dict), "not dict"
except (
AssertionError,
yaml.parser.ParserError,
yaml.scanner.ScannerError,
) as error:
msg_node = self.reporter.error(
"Front matter block:\n" + str(error), line=position
)
Expand Down
6 changes: 5 additions & 1 deletion myst_parser/sphinx_renderer.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,11 @@ class MockSphinx(Sphinx):
def __init__(self, confoverrides=None, srcdir=None, raise_on_warning=False):
self.extensions = {}
self.registry = SphinxComponentRegistry()
self.html_themes = {}
try:
self.html_themes = {}
except AttributeError:
# changed to property in sphinx 4.1
pass
self.events = EventManager(self)

# logging
Expand Down

0 comments on commit 61f1154

Please sign in to comment.