From 1e0aebc3ec1adc1fd02574f61d09ceade6c25321 Mon Sep 17 00:00:00 2001 From: Eugene Yurtsev Date: Fri, 20 Dec 2024 17:38:20 -0500 Subject: [PATCH] x --- docs/_scripts/notebook_hooks.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/docs/_scripts/notebook_hooks.py b/docs/_scripts/notebook_hooks.py index 54cb05de8..b18e3dad5 100644 --- a/docs/_scripts/notebook_hooks.py +++ b/docs/_scripts/notebook_hooks.py @@ -44,7 +44,7 @@ def _highlight_code_blocks(markdown: str) -> str: markdown: The markdown content to process. Returns: - updated markdown code with code blocks containing highlight comments + updated Markdown code with code blocks containing highlight comments updated to use the hl_lines attribute. """ # Pattern to find code blocks with highlight comments and without @@ -87,12 +87,18 @@ def replace_highlight_comments(match: re.Match) -> str: if highlighted_lines: return ( - f'{indent}```{language} hl_lines="{" ".join(highlighted_lines)}"' - f'{new_code_block}' # The indent is already included in the code block - f'\n{indent}```' + f'{indent}```{language} hl_lines="{" ".join(highlighted_lines)}"\n' + # The indent and terminating \n is already included in the code block + f'{new_code_block}' + f'{indent}```' ) else: - return f"{indent}```{language}\n{new_code_block}\n{indent}```" + return ( + f"{indent}```{language}\n" + # The indent and terminating \n is already included in the code block + f"{new_code_block}" + f"{indent}```" + ) # Replace all code blocks in the markdown markdown = code_block_pattern.sub(replace_highlight_comments, markdown)