JaceWei commited on
Commit
8cd17df
·
1 Parent(s): 4fa0474
Files changed (1) hide show
  1. posterbuilder/convert.py +5 -19
posterbuilder/convert.py CHANGED
@@ -609,24 +609,10 @@ def figures_to_latex(fig_list, out_tex_path: pathlib.Path, images_parent: pathli
609
 
610
 
611
  def strip_stray_t(tex: str) -> str:
612
- _T_ALLOWED_PREFIXES = (
613
- # 常见 text 系
614
- "ext", "extbf", "extit", "exttt", "extsc", "extsf",
615
- "extcolor", "extsuperscript", "extsubscript",
616
- "extwidth", "extheight",
617
- # beamer/tikz 等
618
- "itle", "hanks", "ikz", "ikzpicture", "ikzset", "ikzstyle",
619
- # 表格/书签等
620
- "ab", "abular", "able", "abularx", "abcolsep",
621
- # 其他常见
622
- "iny", "ttfamily", "oday", "he", "ypeout",
623
- "oprule", "midrule", "bottomrule", # booktabs
624
- "ocs", "ocsection", "ocsubsection"
625
- )
626
- _T_NONCOMMAND_RE = re.compile(
627
- r'\\([tT])(?!(' + '|'.join(_T_ALLOWED_PREFIXES) + r')|\{)'
628
- )
629
- return _T_NONCOMMAND_RE.sub(lambda m: m.group(1), tex)
630
 
631
  # ===================== 主流程 =====================
632
  def build():
@@ -674,7 +660,7 @@ def build():
674
  cleaned_tex = cleaned_tex.replace(r"\\\\", r"\\") # 避免双转义干扰
675
  cleaned_tex = cleaned_tex.replace(r"\\", "\\") # 最终将 \\ → \
676
  cleaned_tex = cleaned_tex.replace(r"\t\t", "\\t")
677
- # cleaned_tex = strip_stray_t(cleaned_tex)
678
 
679
  OUTPUT_PATH.write_text(cleaned_tex, encoding="utf-8")
680
  print(f"✅ Wrote: {OUTPUT_PATH.relative_to(ROOT_DIR)}")
 
609
 
610
 
611
  def strip_stray_t(tex: str) -> str:
612
+ _T_BEFORE_DOLLAR_RE = re.compile(r'\\t(?=\$)')
613
+ if not tex:
614
+ return tex
615
+ return _T_BEFORE_DOLLAR_RE.sub('', tex)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616
 
617
  # ===================== 主流程 =====================
618
  def build():
 
660
  cleaned_tex = cleaned_tex.replace(r"\\\\", r"\\") # 避免双转义干扰
661
  cleaned_tex = cleaned_tex.replace(r"\\", "\\") # 最终将 \\ → \
662
  cleaned_tex = cleaned_tex.replace(r"\t\t", "\\t")
663
+ cleaned_tex = strip_stray_t(cleaned_tex)
664
 
665
  OUTPUT_PATH.write_text(cleaned_tex, encoding="utf-8")
666
  print(f"✅ Wrote: {OUTPUT_PATH.relative_to(ROOT_DIR)}")