Skip to content

Commit

Permalink
Update process_notebooks.py
Browse files Browse the repository at this point in the history
  • Loading branch information
hakantapanyigit committed Dec 27, 2024
1 parent 0b4c665 commit 245b7ec
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions website/process_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ def convert_callout_blocks(content: str) -> str:
#
# ^(?P<backticks>`{3,4})(?:mdx-code-block|\{=mdx\})[ \t]*\n
# - Matches opening backticks and optional mdx markers.
# :::(?P<callout_type_backtick>...)
# :::(?P<callout_type_backtick>...)
# - Captures the callout type.
# (.*?)
# (.*?)
# - Captures the content inside the callout.
# ^:::[ \t]*\n
# - Matches the closing ::: line.
Expand Down Expand Up @@ -408,7 +408,7 @@ def convert_callout_blocks(content: str) -> str:
r":::(?P<callout_type_backtick>\w+(?:\s+\w+)?)[ \t]*\n"
r"(?P<inner_backtick>.*?)"
r"^:::[ \t]*\n"
r"(?P=backticks)" # Closing backticks must match the opening count.
r"(?P=backticks)" # Closing backticks must match the opening count.
r")"
r"|"
# Alternative #2: Plain ::: callout
Expand All @@ -421,12 +421,12 @@ def convert_callout_blocks(content: str) -> str:

def replace_callout(m: re.Match) -> str:
# Determine the matched alternative and extract the corresponding groups.
ctype = m.group('callout_type_backtick') or m.group('callout_type_no_backtick')
inner = m.group('inner_backtick') or m.group('inner_no_backtick') or ""
ctype = m.group("callout_type_backtick") or m.group("callout_type_no_backtick")
inner = m.group("inner_backtick") or m.group("inner_no_backtick") or ""

# Map the callout type to its standard representation or fallback to the original type.
mapped_type = callout_types.get(ctype, ctype)

# Return the formatted HTML block.
return f"""
<div class="{ctype}">
Expand All @@ -440,7 +440,6 @@ def replace_callout(m: re.Match) -> str:
return pattern.sub(replace_callout, content)



def convert_mdx_image_blocks(content: str, rendered_mdx: Path, website_dir: Path) -> str:
"""
Converts MDX code block image syntax to regular markdown image syntax.
Expand Down

0 comments on commit 245b7ec

Please sign in to comment.