User:Crowley666/code/jp-ref.py
外观
def f(s, xl, discard = True):
ret = []
for x in xl:
t = s.split(x)
ret.append(t[0])
s = t[1]
ret.append(s)
ret = list(filter(lambda x: x, ret))
return ret
def g(s):
return f(s, "* $ 《$》 $年 [[Special:BookSources/$|$]]".split('$'))
def h(xl):
a = xl[0]
t = xl[1]
p = xl[2][0:-5]
y = xl[2][-4:]
i = xl[3]
return "*{{Cite book|author=%s|title=《%s》|publisher=%s|year=%s|isbn=%s|url=|ref={{sfnref|《%s》|%s}}}}" % (a, t, p, y, i, t, y)
def f(s, p, discard = True):
ret = []
while p:
pl = re.split(r'([\^\$])', p, 1)
func = getattr(s, "split" if pl[1] == '^' else "rsplit")
t = func(pl[0], 1)
ret.append(t[0])
s = t[1]
p = pl[2]
ret.append(s)
ret = list(filter(lambda x: x, ret))
return ret
def g(s):
return f(s, "* ^ 《^》 ^ $年 [[Special:BookSources/^|^]]^")
def h(xl):
a = xl[0]
t = xl[1]
p = xl[2][0:-5]
y = xl[2][-4:]
i = xl[3]
return "*{{Cite book|author=%s|title=《%s》|publisher=%s|year=%s|isbn=%s|url=|ref={{sfnref|《%s》|%s}}}}" % (a, t, p, y, i, t, y)