127
127
128
128
--- @return string[]
129
129
function M .validate ()
130
+ --- @param component render.md.debug.ValidatorSpec
131
+ --- @return render.md.debug.ValidatorSpec
132
+ local function component_rules (component )
133
+ return component :type (' enabled' , ' boolean' )
134
+ end
135
+
130
136
--- @param buffer render.md.debug.ValidatorSpec
131
137
--- @return render.md.debug.ValidatorSpec
132
- local function add_buffer_rules (buffer )
138
+ local function buffer_rules (buffer )
133
139
return buffer
134
140
:type (' enabled' , ' boolean' )
135
141
:type ({ ' max_file_size' , ' debounce' }, ' number' )
@@ -153,8 +159,8 @@ function M.validate()
153
159
padding :type (' highlight' , ' string' ):check ()
154
160
end )
155
161
:nested (' heading' , function (heading )
156
- heading
157
- :type ({ ' enabled ' , ' sign' , ' border_virtual' , ' border_prefix' }, ' boolean' )
162
+ component_rules ( heading )
163
+ :type ({ ' sign' , ' border_virtual' , ' border_prefix' }, ' boolean' )
158
164
:type ({ ' above' , ' below' }, ' string' )
159
165
:list (' border' , ' boolean' , ' boolean' )
160
166
:list ({ ' left_margin' , ' left_pad' , ' right_pad' , ' min_width' }, ' number' , ' number' )
@@ -164,10 +170,11 @@ function M.validate()
164
170
:check ()
165
171
end )
166
172
:nested (' paragraph' , function (paragraph )
167
- paragraph : type ( ' enabled ' , ' boolean ' ):type ({ ' left_margin' , ' min_width' }, ' number' ):check ()
173
+ component_rules ( paragraph ):type ({ ' left_margin' , ' min_width' }, ' number' ):check ()
168
174
end )
169
175
:nested (' code' , function (code )
170
- code :type ({ ' enabled' , ' sign' , ' language_name' }, ' boolean' )
176
+ component_rules (code )
177
+ :type ({ ' sign' , ' language_name' }, ' boolean' )
171
178
:type ({ ' language_pad' , ' left_margin' , ' left_pad' , ' right_pad' , ' min_width' }, ' number' )
172
179
:type ({ ' above' , ' below' , ' highlight' , ' highlight_inline' }, ' string' )
173
180
:type (' highlight_language' , { ' string' , ' nil' })
@@ -179,23 +186,21 @@ function M.validate()
179
186
:check ()
180
187
end )
181
188
:nested (' dash' , function (dash )
182
- dash : type ( ' enabled ' , ' boolean ' )
189
+ component_rules ( dash )
183
190
:type (' left_margin' , ' number' )
184
191
:type ({ ' icon' , ' highlight' }, ' string' )
185
192
:one_of (' width' , { ' full' }, ' number' )
186
193
:check ()
187
194
end )
188
195
:nested (' bullet' , function (bullet )
189
- bullet
190
- :type (' enabled' , ' boolean' )
196
+ component_rules (bullet )
191
197
:type ({ ' left_pad' , ' right_pad' }, ' number' )
192
198
:type (' highlight' , ' string' )
193
199
:list_or_list_of_list ({ ' icons' , ' ordered_icons' }, ' string' , ' function' )
194
200
:check ()
195
201
end )
196
202
:nested (' checkbox' , function (checkbox )
197
- checkbox
198
- :type (' enabled' , ' boolean' )
203
+ component_rules (checkbox )
199
204
:one_of (' position' , { ' overlay' , ' inline' })
200
205
:nested ({ ' unchecked' , ' checked' }, function (box )
201
206
box :type ({ ' icon' , ' highlight' }, ' string' ):type (' scope_highlight' , { ' string' , ' nil' }):check ()
@@ -210,11 +215,13 @@ function M.validate()
210
215
:check ()
211
216
end )
212
217
:nested (' quote' , function (quote )
213
- quote :type ({ ' enabled' , ' repeat_linebreak' }, ' boolean' ):type ({ ' icon' , ' highlight' }, ' string' ):check ()
218
+ component_rules (quote )
219
+ :type (' repeat_linebreak' , ' boolean' )
220
+ :type ({ ' icon' , ' highlight' }, ' string' )
221
+ :check ()
214
222
end )
215
223
:nested (' pipe_table' , function (pipe_table )
216
- pipe_table
217
- :type (' enabled' , ' boolean' )
224
+ component_rules (pipe_table )
218
225
:type ({ ' padding' , ' min_width' }, ' number' )
219
226
:type ({ ' alignment_indicator' , ' head' , ' row' , ' filler' }, ' string' )
220
227
:list (' border' , ' string' )
@@ -234,7 +241,7 @@ function M.validate()
234
241
:check ()
235
242
end )
236
243
:nested (' link' , function (link )
237
- link : type ( ' enabled ' , ' boolean ' )
244
+ component_rules ( link )
238
245
:type ({ ' image' , ' email' , ' hyperlink' , ' highlight' }, ' string' )
239
246
:nested (' footnote' , function (footnote )
240
247
footnote :type (' superscript' , ' boolean' ):type ({ ' prefix' , ' suffix' }, ' string' ):check ()
@@ -255,19 +262,19 @@ function M.validate()
255
262
:check ()
256
263
end )
257
264
:nested (' sign' , function (sign )
258
- sign : type ( ' enabled ' , ' boolean ' ):type (' highlight' , ' string' ):check ()
265
+ component_rules ( sign ):type (' highlight' , ' string' ):check ()
259
266
end )
260
- :nested (' inline_highlight' , function (sign )
261
- sign : type ( ' enabled ' , ' boolean ' ):type (' highlight' , ' string' ):check ()
267
+ :nested (' inline_highlight' , function (inline_highlight )
268
+ component_rules ( inline_highlight ):type (' highlight' , ' string' ):check ()
262
269
end )
263
270
:nested (' indent' , function (indent )
264
- indent
265
- :type ({ ' enabled ' , ' skip_heading' } , ' boolean' )
271
+ component_rules ( indent )
272
+ :type (' skip_heading' , ' boolean' )
266
273
:type ({ ' per_level' , ' skip_level' }, ' number' )
267
274
:check ()
268
275
end )
269
276
:nested (' html' , function (html )
270
- html : type ( ' enabled ' , ' boolean ' )
277
+ component_rules ( html )
271
278
:nested (' comment' , function (comment )
272
279
comment
273
280
:type (' conceal' , ' boolean' )
@@ -288,7 +295,7 @@ function M.validate()
288
295
289
296
local validator = require (' render-markdown.debug.validator' ).new ()
290
297
291
- add_buffer_rules (validator :spec (M .config , false ))
298
+ buffer_rules (validator :spec (M .config , false ))
292
299
:type (' log_runtime' , ' boolean' )
293
300
:list (' file_types' , ' string' )
294
301
:one_of (' preset' , { ' none' , ' lazy' , ' obsidian' })
@@ -301,8 +308,7 @@ function M.validate()
301
308
:check ()
302
309
end )
303
310
:nested (' latex' , function (latex )
304
- latex
305
- :type (' enabled' , ' boolean' )
311
+ component_rules (latex )
306
312
:type ({ ' top_pad' , ' bottom_pad' }, ' number' )
307
313
:type ({ ' converter' , ' highlight' }, ' string' )
308
314
:check ()
@@ -315,7 +321,7 @@ function M.validate()
315
321
:nested ({ ' buftype' , ' filetype' }, function (override )
316
322
override
317
323
:nested (' ALL' , function (buffer )
318
- add_buffer_rules (buffer ):check ()
324
+ buffer_rules (buffer ):check ()
319
325
end , true )
320
326
:check ()
321
327
end )
0 commit comments