if escaping: only use on str, else return input
(x, escape)
| 1935 | |
| 1936 | |
| 1937 | def _str_escape(x, escape): |
| 1938 | """if escaping: only use on str, else return input""" |
| 1939 | if isinstance(x, str): |
| 1940 | if escape == "html": |
| 1941 | return escape_html(x) |
| 1942 | elif escape == "latex": |
| 1943 | return _escape_latex(x) |
| 1944 | elif escape == "latex-math": |
| 1945 | return _escape_latex_math(x) |
| 1946 | else: |
| 1947 | raise ValueError( |
| 1948 | f"`escape` only permitted in {{'html', 'latex', 'latex-math'}}, \ |
| 1949 | got {escape}" |
| 1950 | ) |
| 1951 | return x |
| 1952 | |
| 1953 | |
| 1954 | def _render_href(x, format): |