把 Unicode 的 • 统一替换为 LaTeX 的 \\textbullet{},并确保两侧留空格。
(s: str)
| 152 | _BULLET_RE = re.compile(r"•") |
| 153 | |
| 154 | def normalize_inline_bullets(s: str) -> str: |
| 155 | """ |
| 156 | 把 Unicode 的 • 统一替换为 LaTeX 的 \\textbullet{},并确保两侧留空格。 |
| 157 | """ |
| 158 | if not s: |
| 159 | return s |
| 160 | s = _BULLET_RE.sub(r"\\textbullet{}", s) |
| 161 | # 若两侧无空格,补空格(避免“黏连”) |
| 162 | s = re.sub(r"(?<=\S)\\textbullet\{\}(?=\S)", r" \\textbullet{} ", s) |
| 163 | s = re.sub(r"\\textbullet\{\}(?=\S)", r"\\textbullet{} ", s) |
| 164 | s = re.sub(r"(?<=\S)\\textbullet\{\}", r" \\textbullet{}", s) |
| 165 | return s |
| 166 | |
| 167 | def normalize_textit_math(s: str) -> str: |
| 168 | """ |