From 2540ab259ab318c2e1e2f7758b132a199608fe09 Mon Sep 17 00:00:00 2001 From: gautam-divyanshu Date: Sun, 13 Oct 2024 21:56:14 +0530 Subject: [PATCH] mdx file name changed --- .../talawa_admin_md_mdx_format_adjuster.py | 96 +++++++++++++++++++ 1 file changed, 96 insertions(+) create mode 100644 .github/workflows/talawa_admin_md_mdx_format_adjuster.py diff --git a/.github/workflows/talawa_admin_md_mdx_format_adjuster.py b/.github/workflows/talawa_admin_md_mdx_format_adjuster.py new file mode 100644 index 0000000000..cd76a30cf6 --- /dev/null +++ b/.github/workflows/talawa_admin_md_mdx_format_adjuster.py @@ -0,0 +1,96 @@ +#!/usr/bin/env python3 +# -*- coding: UTF-8 -*- +""" +Script to make Markdown files MDX compatible. + +This script scans Markdown files and escapes special characters (<, >, {, }) +to make them compatible with the MDX standard used in Docusaurus v3. + +This script complies with: + 1) Pylint + 2) Pydocstyle + 3) Pycodestyle + 4) Flake8 +""" +import os +import argparse +import re + +def escape_mdx_characters(text): + """ + Escape special characters in a text string for MDX compatibility. + Avoids escaping already escaped characters. + + Args: + text: A string containing the text to be processed. + + Returns: + A string with special characters (<, >, {, }) escaped, avoiding + double escaping. + """ + # Regular expressions to find unescaped special characters + patterns = { + "<": r"(?": r"(?", + "{": r"(?