From f6d3fee855364a3142729f9ea47ccc533e2af6bc Mon Sep 17 00:00:00 2001 From: Sylvain Gugger <35901082+sgugger@users.noreply.github.com> Date: Tue, 18 Jan 2022 07:27:34 -0500 Subject: [PATCH] Error when code examples are improperly closed (#15186) --- utils/style_doc.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/utils/style_doc.py b/utils/style_doc.py index da70c9a2c3..de15a859c7 100644 --- a/utils/style_doc.py +++ b/utils/style_doc.py @@ -445,6 +445,9 @@ def style_mdx_file(mdx_file, max_len=119, check_only=False): else: new_lines.append(line) + if in_code: + raise ValueError(f"There was a problem when styling {mdx_file}. A code block is opened without being closed.") + clean_content = "\n".join(new_lines) diff = clean_content != content if not check_only and diff: