@@ -2,7 +2,6 @@ local Context = require('render-markdown.core.context')
22local list = require (' render-markdown.core.list' )
33local log = require (' render-markdown.core.log' )
44local state = require (' render-markdown.state' )
5- local str = require (' render-markdown.core.str' )
65
76--- @class render.md.handler.buf.Markdown
87--- @field private marks render.md.Marks
@@ -20,7 +19,9 @@ function Handler.new(buf)
2019 self .config = state .get (buf )
2120 self .context = Context .get (buf )
2221 self .renderers = {
22+ checkbox = require (' render-markdown.render.checkbox' ),
2323 code = require (' render-markdown.render.code' ),
24+ dash = require (' render-markdown.render.dash' ),
2425 heading = require (' render-markdown.render.heading' ),
2526 list_marker = require (' render-markdown.render.list_marker' ),
2627 quote = require (' render-markdown.render.quote' ),
@@ -40,54 +41,13 @@ function Handler:parse(root)
4041 if render :setup () then
4142 render :render ()
4243 end
43- elseif capture == ' dash' then
44- self :dash (info )
45- elseif capture == ' checkbox_unchecked' then
46- self :checkbox (info , self .config .checkbox .unchecked )
47- elseif capture == ' checkbox_checked' then
48- self :checkbox (info , self .config .checkbox .checked )
4944 else
5045 log .unhandled_capture (' markdown' , capture )
5146 end
5247 end )
5348 return self .marks :get ()
5449end
5550
56- --- @private
57- --- @param info render.md.NodeInfo
58- function Handler :dash (info )
59- local dash = self .config .dash
60- if not dash .enabled then
61- return
62- end
63-
64- local width = dash .width
65- width = type (width ) == ' number' and width or self .context :get_width ()
66-
67- self .marks :add (true , info .start_row , 0 , {
68- virt_text = { { dash .icon :rep (width ), dash .highlight } },
69- virt_text_pos = ' overlay' ,
70- })
71- end
72-
73- --- @private
74- --- @param info render.md.NodeInfo
75- --- @param checkbox render.md.CheckboxComponent
76- function Handler :checkbox (info , checkbox )
77- if not self .config .checkbox .enabled then
78- return
79- end
80- local inline = self .config .checkbox .position == ' inline'
81- local icon , highlight = checkbox .icon , checkbox .highlight
82- self .marks :add (true , info .start_row , info .start_col , {
83- end_row = info .end_row ,
84- end_col = info .end_col ,
85- virt_text = { { inline and icon or str .pad_to (info .text , icon ) .. icon , highlight } },
86- virt_text_pos = inline and ' inline' or ' overlay' ,
87- conceal = inline and ' ' or nil ,
88- })
89- end
90-
9151--- @class render.md.handler.Markdown : render.md.Handler
9252local M = {}
9353
0 commit comments