Skip to content

Commit

Permalink
Fix: Prevent error from all whitespace lang string (#2036)
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamtaranto authored Aug 27, 2023
1 parent 1011701 commit fad2fdf
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions nbconvert/filters/markdown_mistune.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit fad2fdf

Please sign in to comment.