physics-typst-corpus / scripts /_fix_refrule.py
孟祥瑞
上传 physics-typst 语料(源码/文档,排除PDF等二进制)
e2cb4b5 verified
Raw History Blame Contribute Delete
448 Bytes
p = 'papers/2308.08546/main.typ'
s = open(p, encoding='utf-8').read()
anchor = '#set math.equation(numbering: "(1)", supplement: none)'
assert s.count(anchor) == 1
rule = anchor + '''
#show ref: it => {
let e = it.element
if e != none and e.func() == math.equation {
[(#context counter(math.equation).at(e.location()).first())]
} else { it }
}'''
s = s.replace(anchor, rule, 1)
open(p, 'w', encoding='utf-8').write(s)
print('rule added')