Replace the usage of some characters in units descriptions that might break the mdx compiler

What does this MR do and why?

This MR was raised as a follow up of !3264 (merged). Based on the suggestions, it checks the units descriptions for characters that might break the mdx compiler (chars like '<', '>') and replaces them with their Unicode equivalent.

# Add forbidden character validation and replacement function
def validate_and_replace_markdown_syntax(description, unit_name):
    """
    Validates and replaces Markdown syntax that might raise issues in the unit description.
    """
    # Define a dict of forbidden characters and their replacements
    replacements = {
        '<=': '\u2264',
        '<': '\ufe64',
        '>=': '\u2265',
        '>': '\ufe65'
    }

    # Replace forbidden characters with their equivalent
    for char, replacement in replacements.items():
        if char in description:
            print(f"Replacing '{char}' in unit {unit_name} with unicode equivalent '{replacement}'")
            description = description.replace(char, replacement)

    return description

It iterates over the unit descriptions and checks for forbidden characters, replacing them with their Unicode equivalent.

Related reference(s)

Edited by Dragos Gerea

Merge request reports

Loading