︙ | | |
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
-
+
|
Patterns are written with the Python syntax for regular expressions:
http://docs.python.org/library/re.html
There can be one or several actions for each rule, executed following the order they are
written.
Optional: option, rulename, priority, condition, URL
Optional: option, priority, condition, URL
LCR flags means:
* L: Left boundary for the regex
* C: Case sensitiveness
* R: Right boundary for the regex
|
︙ | | |
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
|
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
|
-
+
-
-
-
-
-
-
-
-
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+
+
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
+
-
+
-
+
|
> `s` case sensitive
> `u` uppercase allowed for lowercase characters
>> i.e.: "Word" becomes "W[oO][rR][dD]"
Examples:
Examples: `[i]`, `<s]`, `[u>`, `<s>`
__[i]__
__<s]__
__[u>__
__<s>__
User option activating/deactivating is possible with an option name placed
just after the LCR flags, i.e.:
__[i]/option1__
__[u]/option2__
__[s>/option1__
__[i]/option1(rulename1)__
__[u]/option2(rulename2)__
__[s>/option3(rulename3)__
__<u>/option3__
__<i>/option3__
Rules can be named:
__[i]/option1(name1)__
__[u]/option2(name2)__
__[s>/option1(name3)__
__<u>(name4)__
__<i>(name5)__
__<u>(rulename4)__
__<i>(rulename5)__
Each rule name must be unique.
The LCR flags are also optional. If you don’t set these flags, the default LCR
flags will be:
__[i]__
Example. Report “foo” in the text and suggest “bar”:
foo <<- ->> bar # Use bar instead of foo.
Example. Recognize and suggest missing hyphen and rewrite internally the text
with the hyphen:
__[s]__
__[s](rulename)__
foo bar
<<- ->> foo-bar # Missing hyphen.
<<- ~>> foo-bar
### Simple-line or multi-line rules
Rules can be break to multiple lines by leading spaces.
You should use 4 spaces.
Examples:
__<s>__ pattern <<- condition ->> replacement # message
__<s>(rulename)__ pattern <<- condition ->> replacement # message
__<s>__
__<s>(rulename)__
pattern
<<- condition ->> replacement
# message
<<- condition ->> suggestion # message
<<- condition ~>> text_rewriting
<<- =>> disambiguation
### Whitespaces at the border of patterns or suggestions
Example: Recognize double or more spaces and suggests a single space:
__<s>__ " +" <<- ->> " " # Remove extra space(s).
__<s>(rulename)__ " +" <<- ->> " " # Remove extra space(s).
Characters `"` protect spaces in the pattern and in the replacement text.
### Pattern groups and back references
It is usually useful to retrieve parts of the matched pattern. We simply use
parenthesis in pattern to get groups with back references.
Example. Suggest a word with correct quotation marks:
\"(\w+)\" <<- ->> “\1” # Correct quotation marks.
Example. Suggest the missing space after the signs `!`, `?` or `.`:
__<i]__ \b([?!.])([A-Z]+) <<- ->> \1 \2 # Missing space?
\b([?!.])([A-Z]+) <<- ->> \1 \2 # Missing space?
Example. Back reference in messages.
(fooo) bar <<- ->> foo # “\1” should be:
### Group positioning codes for JavaScript:
|
︙ | | |
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
|
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
|
-
+
-
+
|
" ([?!;])" @@1
### Pattern matching
Repeating pattern matching of a single rule continues after the previous matching, so instead of general multiword patterns, like
(\w+) (\w+) <<- some_check(\1, \2) ->> \1, \2 # foo
(\w+) (\w+) <<- some_check(\1, \2) ->> \1, \2 # foo
use
(\w+) <<- some_check(\1, word(1)) ->> \1, # foo
(\w+) <<- some_check(\1, word(1)) ->> \1, # foo
## TOKEN RULES ##
Token rules must be defined within a graph.
### Token rules syntax
|
︙ | | |
417
418
419
420
421
422
423
424
425
426
427
428
429
430
|
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
|
+
+
+
+
|
`sCountry`
> Contains the current country locale of the checked paragraph.
colour <<- sCountry == "US" ->> color # Use American English spelling.
`sContext`
> The name of the application running (Python, Writer…)
## ACTIONS ##
There are 5 kinds of actions:
1. Suggestions. The grammar checker suggests corrections.
2. Text processor. A internal process to modify the text internally. This is used to simplify grammar checking.
|
︙ | | |