def _str_escape(x, escape): """if escaping: only use on str, else return input""" if isinstance(x, str): if escape == "html": return escape_html(x) elif escape == "latex": return _escape_latex(x) else: raise ValueError( f"`escape` only permitted in {{'html', 'latex'}}, got {escape}" ) return x
def _str_escape_html(x): """if escaping html: only use on str, else return input""" if isinstance(x, str): return escape_html(x) return x