def escape_pattern()

in python/moz/l10n/formats/android/serialize.py [0:0]


def escape_pattern(el: etree._Element) -> None:
    if el.text and el.text.startswith((" ", "@", "?")):
        el.text = escape_char(el.text[0]) + el.text[1:]
    if len(el) > 0:
        last = el[-1]
        if last.tail and last.tail.endswith(" "):
            last.tail = last.tail[:-1] + escape_char(" ")
    elif el.text and el.text.endswith(" "):
        el.text = el.text[:-1] + escape_char(" ")