MCPcopy
hub / github.com/pandas-dev/pandas / _math_mode_with_dollar

Function _math_mode_with_dollar

pandas/io/formats/style_render.py:2579–2609  ·  view source on GitHub ↗

r""" All characters in LaTeX math mode are preserved. The substrings in LaTeX math mode, which start with the character ``$`` and end with ``$``, are preserved without escaping. Otherwise regular LaTeX escaping applies. Parameters ---------- s : str Input to be

(s: str)

Source from the content-addressed store, hash-verified

2577
2578
2579def _math_mode_with_dollar(s: str) -> str:
2580 r"""
2581 All characters in LaTeX math mode are preserved.
2582
2583 The substrings in LaTeX math mode, which start with
2584 the character ``$`` and end with ``$``, are preserved
2585 without escaping. Otherwise regular LaTeX escaping applies.
2586
2587 Parameters
2588 ----------
2589 s : str
2590 Input to be escaped
2591
2592 Return
2593 ------
2594 str :
2595 Escaped string
2596 """
2597 s = s.replace(r"\$", r"rt8§=§7wz")
2598 pattern = re.compile(r"\$.*?\$")
2599 pos = 0
2600 ps = pattern.search(s, pos)
2601 res = []
2602 while ps:
2603 res.append(_escape_latex(s[pos : ps.span()[0]]))
2604 res.append(ps.group())
2605 pos = ps.span()[1]
2606 ps = pattern.search(s, pos)
2607
2608 res.append(_escape_latex(s[pos : len(s)]))
2609 return "".join(res).replace(r"rt8§=§7wz", r"\$")
2610
2611
2612def _math_mode_with_parentheses(s: str) -> str:

Callers 1

_escape_latex_mathFunction · 0.85

Calls 4

_escape_latexFunction · 0.85
replaceMethod · 0.45
appendMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected