Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes bug in md mdx format adjuster.py #2698

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/talawa_mobile_md_mdx_format_adjuster.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,28 +18,28 @@
import argparse
import re

def escape_mdx_characters(text):
"""
Escape special characters (<, >, {, }) in Dart docs to make them MDX compatible.

Args:
text (str): The text content to be processed.

Returns:
str: The modified string with escaped MDX characters.
"""
# Replace unescaped <, >, {, } with their escaped equivalents
patterns = {
"<": r"(?<!\\)<",
">": r"(?<!\\)>",
"{": r"(?<!\\){",
"}": r"(?<!\\)}"
}
# def escape_mdx_characters(text):
# """
# Escape special characters (<, >, {, }) in Dart docs to make them MDX compatible.

# Args:
# text (str): The text content to be processed.

# Returns:
# str: The modified string with escaped MDX characters.
# """
# # Replace unescaped <, >, {, } with their escaped equivalents
# patterns = {
# "<": r"(?<!\\)<",
# ">": r"(?<!\\)>",
# "{": r"(?<!\\){",
# "}": r"(?<!\\)}"
# }

for char, pattern in patterns.items():
text = re.sub(pattern, f"\\{char}", text)
# for char, pattern in patterns.items():
# text = re.sub(pattern, f"\\{char}", text)

return text
# return text

def adjust_dart_code_blocks(text):
"""
Expand Down Expand Up @@ -76,7 +76,7 @@ def process_file(filepath):
content = file.read()

# Escape MDX special characters
content = escape_mdx_characters(content)
# content = escape_mdx_characters(content)
# Adjust Dart code blocks for MDX
content = adjust_dart_code_blocks(content)

Expand Down
Loading