forked from yfpeng/pengyifan-bibtexformat
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubstitutions.cfg
31 lines (28 loc) · 1.31 KB
/
substitutions.cfg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#
# Regular expressions that are carried out for each line of the BibTeX library
# For help with regular expressions please see http://www.regular-expressions.info
#
# These substitutions happen before each entry is fully parsed. It is not possible at
# this stage to refer to the beginning and end of the field with ^ and $, respectively.
# For such tasks, -fieldregex can be used via the command line (or the runscript).
#
# CAUTION:
# Each line is evaluated by Perl, therefore, some characters have to be escaped, i.e.
# preceded by a backslash:
# - dollar signs $ = \$
# - backslash \ = \\
# - regular expression control characters such as * . + [ ] etc.
#
# replace "n-p*" with $n\rightarrow\pi^{*}$"
$Line =~ s/n-p\*/\$n\\rightarrow\\pi^\{*\}\$/ig;
$Line =~ s/p-p\*/\$\\pi\\rightarrow\\pi^\{*\}\$/ig;
# replace "alpha" or "beta" in the text with $\alpha$ or $\beta$
# ([^\$][^\\]) = not preceded by "\$\" (then it was escaped before), this match is put into $1
# [Aa]lpha = match "Alpha" and "alpha"
# ([\s-]) = followed by a blank or a dash, this match is put into $2
$Line =~ s/([^\$][^\\])[Aa]lpha([\s-])/$1\$\\alpha\$$2/g;
$Line =~ s/([^\$][^\\])[Bb]eta([\s-])/$1\$\\beta\$$2/g;
# replace "Ca2+" with "Ca$^{2+}$"
$Line =~ s/Ca2\+/Ca\$^{2+}\$/g;
# replace "HF- " with "HF$^-$"
$Line =~ s/HF- /HF\$^-\$ /g;