-
Notifications
You must be signed in to change notification settings - Fork 2
/
parser.cfg
215 lines (182 loc) · 6.24 KB
/
parser.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
#
# Remove Comments that Scrivener needs to ignore plain LaTeX.
# Actually we could just not anymore write even those comments
# into Scrivener; yet in the Scrivenings view, it may be nicer
# not to see plain LaTeX code.
#
'<!--' => '" "',
'-->' => '" "',
#
# Quotes (the order is important!)
#
'"(\s)' => '"\'\'$1"', # end of double quote
'(\s)\'' => '"$1`"', # start of single quote
'(\s)"' => '"$1``"', # start of double quote
'^\'' => '"`"', # single quote at line start
'^"' => '"``"', # double quote at line start
'"$' => '"\'\'"', # double quote at line end
'\("' => '"(``"', # double quote after (
'"\)' => '"'')"', # double quote before )
'``\'' => '"``\thinspace`"', # start of triple quote
'\'\'\'' => '"\'\thinspace\'\'"', # end of triple quote
#
# Convert Section headings etc. and add labels
#
# Labels are the section headers, with spaces converted to dashes
#
# So for example, if you do
#
# ### Methodology and Constraints
#
# You get
#
# \section{Methodology and Constraints}\label{Methodology-and-Constraints}
#
# So that later you can refer to it like so:
#
# [r^ Methodology and Constraints]
#
# Which will be converted to (see further below)
#
# \ref{Methodology-and-Constraints}
#
#
'^# (.*?)$' => '"\part{$1}\label{".nomarkdown(nospace($1))."}"',
'^## (.*?)$' => '"\chapter{$1}\label{".nomarkdown(nospace($1))."}"',
'^### (.*?)$' => '"\section{$1}\label{".nomarkdown(nospace($1))."}"',
'^#### (.*?)$' => '"\subsection{$1}\label{".nomarkdown(nospace($1))."}"',
'^##### (.*?)$' => '"\subsubsection{$1}\label{".nomarkdown(nospace($1))."}"',
'^###### (.*?)$' => '"\paragraph{$1}\label{".nomarkdown(nospace($1))."}"',
'^####### (.*?)$' => '"\subparagraph{$1}\label{".nomarkdown(nospace($1))."}"',
'^#\* (.*?)$' => '"\part*{$1}\label{".nomarkdown(nospace($1))."}"',
'^##\* (.*?)$' => '"\chapter*{$1}\label{".nomarkdown(nospace($1))."}"',
'^###\* (.*?)$' => '"\section*{$1}\label{".nomarkdown(nospace($1))."}"',
'^####\* (.*?)$' => '"\subsection*{$1}\label{".nomarkdown(nospace($1))."}"',
'^#####\* (.*?)$' => '"\subsubsection*{$1}\label{".nomarkdown(nospace($1))."}"',
'^######\* (.*?)$' => '"\paragraph*{$1}\label{".nomarkdown(nospace($1))."}"',
'^#######\* (.*?)$' => '"\subparagraph*{$1}\label{".nomarkdown(nospace($1))."}"',
'^#\[([^]]*)\] (.*?)$' => '"\part[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^##\[([^]]*)\] (.*?)$' => '"\chapter[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^###\[([^]]*)\] (.*?)$' => '"\section[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^####\[([^]]*)\] (.*?)$' => '"\subsection[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^#####\[([^]]*)\] (.*?)$' => '"\subsubsection[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^######\[([^]]*)\] (.*?)$' => '"\paragraph[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
'^#######\[([^]]*)\] (.*?)$' => '"\subparagraph[$1]{$2}\label{".nomarkdown(nospace($2))."}"',
# Section labels should not have LaTeX commands. That's what we use
# nomarkdown for above. This could result in empty labels. These we
# remove.
'\\label\{\}' => '""',
#
# Footnotes
#
# __xyz__ => \footnote{xyz}
#
#'\|\^\s*([^|]*)\|' => '"\footnote{$1}"',
#'\^\^\s*([^^]*)\^\^' => '"\footnote{$1}"',
'__\s*([^_]*)__' => '"\footnote{$1}"',
#
# Citations
#
# We support
#
# [#], [p#] => citep
# [a#] => citeauthor
# [c#] => cite
# [t#] => citet
# [y#] => citeyear
# [yp#] => (citeyear)
#
# All of them take an optional () in front of the []
# and will parse this in as for the pages section.
# So for example:
#
# (20-30)[#xyz] => \citep[20-30]{xyz}
#
# Alternativel, for "ibd." citations, you can use
# the shorthand "i", so like [i#], [yi#], etc:
#
# [ypi#xyz] => (\citeyear[ibd.]{xyz})
#
#
# (xyz)[#auth,...] => \citep[xyz]{auth,...}
# [#auth,...] => \citep{auth,...}
# (xyz)[p#auth,...] => \citep[xyz]{auth,...}
# [p#auth,...] => \citep{auth,...}
#
'\(([^()]*)\)\[#\s*([^]]*)\]' => '"\citep[$1]{$2}"',
'\[i#\s*([^]]*)\]' => '"\citep[ibd.]{$1}"',
'\[#\s*([^]]*)\]' => '"\citep{$1}"',
'\(([^()]*)\)\[p#\s*([^]]*)\]' => '"\citep[$1]{$2}"',
'\[pi#\s*([^]]*)\]' => '"\citep[ibd.]{$1}"',
'\[p#\s*([^]]*)\]' => '"\citep{$1}"',
#
# (xyz)[a#auth,...] => \citeauthor[xyz]{auth,...}
# [a#auth,...] => \citeauthor{auth,...}
#
'\(([^()]*)\)\[a#\s*([^]]*)\]' => '"\citeauthor[$1]{$2}"',
'\[ai#\s*([^]]*)\]' => '"\citeauthor[ibd.]{$1}"',
'\[a#\s*([^]]*)\]' => '"\citeauthor{$1}"',
#
# (xyz)[c#auth,...] => \cite[xyz]{auth,...}
# [c#auth,...] => \cite{auth,...}
#
'\(([^()]*)\)\[c#\s*([^]]*)\]' => '"\cite[$1]{$2}"',
'\[ci#\s*([^]]*)\]' => '"\cite[ibd.]{$1}"',
'\[c#\s*([^]]*)\]' => '"\cite{$1}"',
#
# (xyz)[t#auth,...] => \citet[xyz]{auth,...}
# [t#auth,...] => \citet{auth,...}
#
'\(([^()]*)\)\[t#\s*([^]]*)\]' => '"\citet[$1]{$2}"',
'\[ti#\s*([^]]*)\]' => '"\citet[ibd.]{$1}"',
'\[t#\s*([^]]*)\]' => '"\citet{$1}"',
#
# (xyz)[y#auth,...] => \citeyear[xyz]{auth,...}
# [y#auth,...] => \citeyear{auth,...}
#
'\(([^()]*)\)\[y#\s*([^]]*)\]' => '"\citeyear[$1]{$2}"',
'\[yi#\s*([^]]*)\]' => '"\citeyear[ibd.]{$1}"',
'\[y#\s*([^]]*)\]' => '"\citeyear{$1}"',
#
# (xyz)[yp#auth,...] => (\citeyear[xyz]{auth,...})
# [yp#auth,...] => (\citeyear{auth,...})
#
'\(([^()]*)\)\[yp#\s*([^]]*)\]' => '"(\citeyear[$1]{$2})"',
'\[ypi#\s*([^]]*)\]' => '"(\citeyear[ibd.]{$1})"',
'\[yp#\s*([^]]*)\]' => '"(\citeyear{$1})"',
#
# [title#auth,...] => \citetitle{auth,...}
#
'\[title#\s*([^]]*)\]' => '"\citetitle{$1}"',
#
# Labels
#
# Spaces, except leading spaces, are converted to dashes
#
# [l# abc] => \label{abc}
#
'\[l#\s*([^]]*)\]' => '"\label{".nospace($1)."}"',
#
# References
#
# If the reference contains spaces, they are converted to dashes
# except for leading spaces, which are removed
#
# [r# abc] => \ref{abc}
# [vr# abc] => \vref{abc}
# [pr# abc] => \pageref{abc}
# [er# abc] => \eqref{abc}
#
'\[r#\s*([^]]*)\]' => '"\ref{".nospace($1)."}"',
'\[pr#\s*([^]]*)\]' => '"\pageref{".nospace($1)."}"',
'\[vr#\s*([^]]*)\]' => '"\vref{".nospace($1)."}"',
'\[er#\s*([^]]*)\]' => '"\eqref{".nospace($1)."}"',
#
# Emphasis
#
# **xyz** => \textbf{xyz}
# *xyz* => \emph{xyz}
#
#'\*\*\*\s*([^*\s]*)\s*\*\*\*' => '"\emph{$1}"',
'\*\*([^*]*)\*\*' => '"\textbf{$1}"',
'\*([^*]*)\*' => '"\emph{$1}"',