From fad2fdfabe5fbb311424d59243c6a36ccb1468cb Mon Sep 17 00:00:00 2001 From: Adam Taranto Date: Mon, 28 Aug 2023 04:53:14 +1000 Subject: [PATCH] Fix: Prevent error from all whitespace lang string (#2036) --- nbconvert/filters/markdown_mistune.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nbconvert/filters/markdown_mistune.py b/nbconvert/filters/markdown_mistune.py index 91ae1c1e9..5ad2142cf 100644 --- a/nbconvert/filters/markdown_mistune.py +++ b/nbconvert/filters/markdown_mistune.py @@ -299,8 +299,9 @@ def block_code(self, code: str, info: Optional[str] = None) -> str: return self.block_mermaidjs(code) try: - lang = info.strip().split(maxsplit=1)[0] - lexer = get_lexer_by_name(lang, stripall=True) + if info.strip().split(None, 1): + lang = info.strip().split(maxsplit=1)[0] + lexer = get_lexer_by_name(lang, stripall=True) except ClassNotFound: code = f"{lang}\n{code}" lang = None