Skip to content

Commit 308f9a8

Browse files
Add language code style
# Details Requested: #52 Adds ability to overlay language icon / name above code blocks without the touching the background.
1 parent 47ebd7d commit 308f9a8

File tree

6 files changed

+15
-10
lines changed

6 files changed

+15
-10
lines changed

Diff for: README.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,8 @@ require('render-markdown').setup({
183183
-- Determines how code blocks are rendered:
184184
-- none: disables all rendering
185185
-- normal: adds highlight group to the code block
186-
-- full: normal + language icon & name above the code block
186+
-- language: adds language icon & name above the code block
187+
-- full: normal + language
187188
style = 'full',
188189
-- Highlight for code blocks
189190
highlight = 'ColorColumn',
@@ -325,7 +326,8 @@ require('render-markdown').setup({
325326
-- Determines how code blocks are rendered:
326327
-- none: disables all rendering
327328
-- normal: adds highlight group to the code block
328-
-- full: normal + language icon & name above the code block
329+
-- language: adds language icon & name above the code block
330+
-- full: normal + language
329331
style = 'full',
330332
-- Highlight for code blocks
331333
highlight = 'ColorColumn',

Diff for: doc/render-markdown.txt

+4-2
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,8 @@ Full Default Configuration ~
219219
-- Determines how code blocks are rendered:
220220
-- none: disables all rendering
221221
-- normal: adds highlight group to the code block
222-
-- full: normal + language icon & name above the code block
222+
-- language: adds language icon & name above the code block
223+
-- full: normal + language
223224
style = 'full',
224225
-- Highlight for code blocks
225226
highlight = 'ColorColumn',
@@ -361,7 +362,8 @@ CODE BLOCKS *render-markdown-setup-code-blocks*
361362
-- Determines how code blocks are rendered:
362363
-- none: disables all rendering
363364
-- normal: adds highlight group to the code block
364-
-- full: normal + language icon & name above the code block
365+
-- language: adds language icon & name above the code block
366+
-- full: normal + language
365367
style = 'full',
366368
-- Highlight for code blocks
367369
highlight = 'ColorColumn',

Diff for: lua/render-markdown/handler/markdown.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ M.render_node = function(namespace, buf, capture, node)
6060
})
6161
elseif capture == 'code' then
6262
local code = state.config.code
63-
if code.style == 'none' then
63+
if not vim.tbl_contains({ 'normal', 'full' }, code.style) then
6464
return
6565
end
6666

@@ -72,7 +72,7 @@ M.render_node = function(namespace, buf, capture, node)
7272
})
7373
elseif capture == 'language' then
7474
local code = state.config.code
75-
if code.style ~= 'full' then
75+
if not vim.tbl_contains({ 'language', 'full' }, code.style) then
7676
return
7777
end
7878
-- Requires inline extmarks

Diff for: lua/render-markdown/health.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ function M.check_config(config)
153153

154154
local code = config.code
155155
append_errors('code', {
156-
style = one_of(code.style, { 'full', 'normal', 'none' }),
156+
style = one_of(code.style, { 'full', 'language', 'normal', 'none' }),
157157
highlight = { code.highlight, 'string' },
158158
})
159159

Diff for: lua/render-markdown/init.lua

+3-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ local M = {}
3636
---@field public highlight? string
3737

3838
---@class render.md.UserCode
39-
---@field public style? 'full'|'normal'|'none'
39+
---@field public style? 'full'|'normal'|'language'|'none'
4040
---@field public highlight? string
4141

4242
---@class render.md.UserHeading
@@ -155,7 +155,8 @@ M.default_config = {
155155
-- Determines how code blocks are rendered:
156156
-- none: disables all rendering
157157
-- normal: adds highlight group to the code block
158-
-- full: normal + language icon & name above the code block
158+
-- language: adds language icon & name above the code block
159+
-- full: normal + language
159160
style = 'full',
160161
-- Highlight for code blocks
161162
highlight = 'ColorColumn',

Diff for: lua/render-markdown/types.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
---@field public highlight string
2424

2525
---@class render.md.Code
26-
---@field public style 'full'|'normal'|'none'
26+
---@field public style 'full'|'normal'|'language'|'none'
2727
---@field public highlight string
2828

2929
---@class render.md.Heading

0 commit comments

Comments
 (0)