MCPcopy Create free account
hub / github.com/BIT-DataLab/Edit-Banana / _escape_text

Method _escape_text

modules/text/xml_generator.py:135–149  ·  view source on GitHub ↗

转义文本内容 - HTML 特殊字符转义 - LaTeX 公式转换为 MathJax 格式 \\(公式\\)

(self, text: str, is_latex: bool = False)

Source from the content-addressed store, hash-verified

133 return ";".join(styles) + ";"
134
135 def _escape_text(self, text: str, is_latex: bool = False) -> str:
136 """
137 转义文本内容
138
139 - HTML 特殊字符转义
140 - LaTeX 公式转换为 MathJax 格式 \\(公式\\)
141 """
142 escaped = html.escape(text)
143
144 if is_latex:
145 # 移除 $ 符号,转换为 MathJax 格式
146 latex_content = escaped.replace("$", "").strip()
147 escaped = f"\\({latex_content}\\)"
148
149 return escaped
150
151 def generate_xml(self, cells: list[TextCellData]) -> str:
152 """

Callers 1

_add_text_cellMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected