Skip to content

Commit

Permalink
Fix sanity check failures due to new mistune version (pytorch#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasHug authored Dec 14, 2021
1 parent d7ad5d5 commit 94f0352
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions scripts/sanity_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,16 @@ def no_extra_colon(self, field, value):
.format(field, value, self.filename))

def validate_markdown(self, markdown):
m = mistune.Markdown()
blocks = m.block(mistune.preprocessing(markdown))
m = mistune.create_markdown(renderer=mistune.AstRenderer())

for block in blocks:
for block in m(markdown):
if block['type'] == 'heading':
# we dont want colon after section names
assert not block['text'].endswith(':')
if block['text'] in self.required_sections:
self.required_sections.remove(block['text'])
text_children = [c for c in block['children'] if c['type'] == 'text']
for c in text_children:
assert not c['text'].endswith(':')
if c['text'] in self.required_sections:
self.required_sections.remove(c['text'])
try:
assert len(self.required_sections) == 0
except AssertionError as e:
Expand Down

0 comments on commit 94f0352

Please sign in to comment.