Skip to content

Commit e19ed93

Browse files
Fix behavior with code style: language
## Details When using language style do not add the `code` highlight group to language extmark. Use same style setting in markdown_inline to disable highlights.
1 parent b2da013 commit e19ed93

File tree

6 files changed

+32
-22
lines changed

6 files changed

+32
-22
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,13 @@ require('render-markdown').setup({
180180
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
181181
},
182182
code = {
183-
-- Determines how code blocks are rendered:
183+
-- Determines how code blocks & inline code are rendered:
184184
-- none: disables all rendering
185-
-- normal: adds highlight group to the code block
186-
-- language: adds language icon & name above the code block
185+
-- normal: adds highlight group to code blocks & inline code
186+
-- language: adds language icon & name above code blocks
187187
-- full: normal + language
188188
style = 'full',
189-
-- Highlight for code blocks
189+
-- Highlight for code blocks & inline code
190190
highlight = 'ColorColumn',
191191
},
192192
dash = {
@@ -332,13 +332,13 @@ require('render-markdown').setup({
332332
```lua
333333
require('render-markdown').setup({
334334
code = {
335-
-- Determines how code blocks are rendered:
335+
-- Determines how code blocks & inline code are rendered:
336336
-- none: disables all rendering
337-
-- normal: adds highlight group to the code block
338-
-- language: adds language icon & name above the code block
337+
-- normal: adds highlight group to code blocks & inline code
338+
-- language: adds language icon & name above code blocks
339339
-- full: normal + language
340340
style = 'full',
341-
-- Highlight for code blocks
341+
-- Highlight for code blocks & inline code
342342
highlight = 'ColorColumn',
343343
},
344344
})

doc/render-markdown.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,13 +216,13 @@ Full Default Configuration ~
216216
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
217217
},
218218
code = {
219-
-- Determines how code blocks are rendered:
219+
-- Determines how code blocks & inline code are rendered:
220220
-- none: disables all rendering
221-
-- normal: adds highlight group to the code block
222-
-- language: adds language icon & name above the code block
221+
-- normal: adds highlight group to code blocks & inline code
222+
-- language: adds language icon & name above code blocks
223223
-- full: normal + language
224224
style = 'full',
225-
-- Highlight for code blocks
225+
-- Highlight for code blocks & inline code
226226
highlight = 'ColorColumn',
227227
},
228228
dash = {
@@ -368,13 +368,13 @@ CODE BLOCKS *render-markdown-setup-code-blocks*
368368
>lua
369369
require('render-markdown').setup({
370370
code = {
371-
-- Determines how code blocks are rendered:
371+
-- Determines how code blocks & inline code are rendered:
372372
-- none: disables all rendering
373-
-- normal: adds highlight group to the code block
374-
-- language: adds language icon & name above the code block
373+
-- normal: adds highlight group to code blocks & inline code
374+
-- language: adds language icon & name above code blocks
375375
-- full: normal + language
376376
style = 'full',
377-
-- Highlight for code blocks
377+
-- Highlight for code blocks & inline code
378378
highlight = 'ColorColumn',
379379
},
380380
})

lua/render-markdown/handler/markdown.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,12 @@ M.render_node = function(namespace, buf, capture, node)
8080
if icon == nil or icon_highlight == nil then
8181
return
8282
end
83+
local highlight = { icon_highlight }
84+
if code.style == 'full' then
85+
highlight = { icon_highlight, code.highlight }
86+
end
8387
vim.api.nvim_buf_set_extmark(buf, namespace, start_row, start_col, {
84-
virt_text = { { icon .. ' ' .. value, { icon_highlight, code.highlight } } },
88+
virt_text = { { icon .. ' ' .. value, highlight } },
8589
virt_text_pos = 'inline',
8690
})
8791
elseif capture == 'list_marker' then

lua/render-markdown/handler/markdown_inline.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,14 @@ M.render_node = function(namespace, buf, capture, node)
2626
logger.debug_node(capture, node, buf)
2727

2828
if capture == 'code' then
29+
local code = state.config.code
30+
if not vim.tbl_contains({ 'normal', 'full' }, code.style) then
31+
return
32+
end
2933
vim.api.nvim_buf_set_extmark(buf, namespace, start_row, start_col, {
3034
end_row = end_row,
3135
end_col = end_col,
32-
hl_group = state.config.code.highlight,
36+
hl_group = code.highlight,
3337
})
3438
elseif capture == 'callout' then
3539
local callout = component.callout(value, 'exact')

lua/render-markdown/health.lua

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,9 +204,11 @@ function M.check_config(config)
204204
append_errors('pipe_table', {
205205
style = one_of(pipe_table.style, { 'full', 'normal', 'none' }),
206206
cell = one_of(pipe_table.cell, { 'overlay', 'raw' }),
207+
boarder = { pipe_table.boarder, 'table' },
207208
head = { pipe_table.head, 'string' },
208209
row = { pipe_table.row, 'string' },
209210
})
211+
all_strings('pipe_table.boarder', pipe_table.boarder)
210212

211213
for name, component in pairs(config.callout) do
212214
append_errors('callout.' .. name, {

lua/render-markdown/init.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,13 +153,13 @@ M.default_config = {
153153
foregrounds = { 'markdownH1', 'markdownH2', 'markdownH3', 'markdownH4', 'markdownH5', 'markdownH6' },
154154
},
155155
code = {
156-
-- Determines how code blocks are rendered:
156+
-- Determines how code blocks & inline code are rendered:
157157
-- none: disables all rendering
158-
-- normal: adds highlight group to the code block
159-
-- language: adds language icon & name above the code block
158+
-- normal: adds highlight group to code blocks & inline code
159+
-- language: adds language icon & name above code blocks
160160
-- full: normal + language
161161
style = 'full',
162-
-- Highlight for code blocks
162+
-- Highlight for code blocks & inline code
163163
highlight = 'ColorColumn',
164164
},
165165
dash = {

0 commit comments

Comments
 (0)