127127
128128--- @return string[]
129129function 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+
130136 --- @param buffer render.md.debug.ValidatorSpec
131137 --- @return render.md.debug.ValidatorSpec
132- local function add_buffer_rules (buffer )
138+ local function buffer_rules (buffer )
133139 return buffer
134140 :type (' enabled' , ' boolean' )
135141 :type ({ ' max_file_size' , ' debounce' }, ' number' )
@@ -153,8 +159,8 @@ function M.validate()
153159 padding :type (' highlight' , ' string' ):check ()
154160 end )
155161 :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' )
158164 :type ({ ' above' , ' below' }, ' string' )
159165 :list (' border' , ' boolean' , ' boolean' )
160166 :list ({ ' left_margin' , ' left_pad' , ' right_pad' , ' min_width' }, ' number' , ' number' )
@@ -164,10 +170,11 @@ function M.validate()
164170 :check ()
165171 end )
166172 :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 ()
168174 end )
169175 :nested (' code' , function (code )
170- code :type ({ ' enabled' , ' sign' , ' language_name' }, ' boolean' )
176+ component_rules (code )
177+ :type ({ ' sign' , ' language_name' }, ' boolean' )
171178 :type ({ ' language_pad' , ' left_margin' , ' left_pad' , ' right_pad' , ' min_width' }, ' number' )
172179 :type ({ ' above' , ' below' , ' highlight' , ' highlight_inline' }, ' string' )
173180 :type (' highlight_language' , { ' string' , ' nil' })
@@ -179,23 +186,21 @@ function M.validate()
179186 :check ()
180187 end )
181188 :nested (' dash' , function (dash )
182- dash : type ( ' enabled ' , ' boolean ' )
189+ component_rules ( dash )
183190 :type (' left_margin' , ' number' )
184191 :type ({ ' icon' , ' highlight' }, ' string' )
185192 :one_of (' width' , { ' full' }, ' number' )
186193 :check ()
187194 end )
188195 :nested (' bullet' , function (bullet )
189- bullet
190- :type (' enabled' , ' boolean' )
196+ component_rules (bullet )
191197 :type ({ ' left_pad' , ' right_pad' }, ' number' )
192198 :type (' highlight' , ' string' )
193199 :list_or_list_of_list ({ ' icons' , ' ordered_icons' }, ' string' , ' function' )
194200 :check ()
195201 end )
196202 :nested (' checkbox' , function (checkbox )
197- checkbox
198- :type (' enabled' , ' boolean' )
203+ component_rules (checkbox )
199204 :one_of (' position' , { ' overlay' , ' inline' })
200205 :nested ({ ' unchecked' , ' checked' }, function (box )
201206 box :type ({ ' icon' , ' highlight' }, ' string' ):type (' scope_highlight' , { ' string' , ' nil' }):check ()
@@ -210,11 +215,13 @@ function M.validate()
210215 :check ()
211216 end )
212217 :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 ()
214222 end )
215223 :nested (' pipe_table' , function (pipe_table )
216- pipe_table
217- :type (' enabled' , ' boolean' )
224+ component_rules (pipe_table )
218225 :type ({ ' padding' , ' min_width' }, ' number' )
219226 :type ({ ' alignment_indicator' , ' head' , ' row' , ' filler' }, ' string' )
220227 :list (' border' , ' string' )
@@ -234,7 +241,7 @@ function M.validate()
234241 :check ()
235242 end )
236243 :nested (' link' , function (link )
237- link : type ( ' enabled ' , ' boolean ' )
244+ component_rules ( link )
238245 :type ({ ' image' , ' email' , ' hyperlink' , ' highlight' }, ' string' )
239246 :nested (' footnote' , function (footnote )
240247 footnote :type (' superscript' , ' boolean' ):type ({ ' prefix' , ' suffix' }, ' string' ):check ()
@@ -255,19 +262,19 @@ function M.validate()
255262 :check ()
256263 end )
257264 :nested (' sign' , function (sign )
258- sign : type ( ' enabled ' , ' boolean ' ):type (' highlight' , ' string' ):check ()
265+ component_rules ( sign ):type (' highlight' , ' string' ):check ()
259266 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 ()
262269 end )
263270 :nested (' indent' , function (indent )
264- indent
265- :type ({ ' enabled ' , ' skip_heading' } , ' boolean' )
271+ component_rules ( indent )
272+ :type (' skip_heading' , ' boolean' )
266273 :type ({ ' per_level' , ' skip_level' }, ' number' )
267274 :check ()
268275 end )
269276 :nested (' html' , function (html )
270- html : type ( ' enabled ' , ' boolean ' )
277+ component_rules ( html )
271278 :nested (' comment' , function (comment )
272279 comment
273280 :type (' conceal' , ' boolean' )
@@ -288,7 +295,7 @@ function M.validate()
288295
289296 local validator = require (' render-markdown.debug.validator' ).new ()
290297
291- add_buffer_rules (validator :spec (M .config , false ))
298+ buffer_rules (validator :spec (M .config , false ))
292299 :type (' log_runtime' , ' boolean' )
293300 :list (' file_types' , ' string' )
294301 :one_of (' preset' , { ' none' , ' lazy' , ' obsidian' })
@@ -301,8 +308,7 @@ function M.validate()
301308 :check ()
302309 end )
303310 :nested (' latex' , function (latex )
304- latex
305- :type (' enabled' , ' boolean' )
311+ component_rules (latex )
306312 :type ({ ' top_pad' , ' bottom_pad' }, ' number' )
307313 :type ({ ' converter' , ' highlight' }, ' string' )
308314 :check ()
@@ -315,7 +321,7 @@ function M.validate()
315321 :nested ({ ' buftype' , ' filetype' }, function (override )
316322 override
317323 :nested (' ALL' , function (buffer )
318- add_buffer_rules (buffer ):check ()
324+ buffer_rules (buffer ):check ()
319325 end , true )
320326 :check ()
321327 end )
0 commit comments