Skip to content

Commit b292624

Browse files
feat: padding character for inline code
## Details Request: #389 Allows users to set text values for `code.inline_left` & `code.inline_right` which will be added to the left and right of inline code blocks. Will be combined with `code.inline_pad`. Example using half circles: ```lua require('render-markdown').setup({ code = { inline_left = '', inline_right = '' }, }) ``` Highlight gets created by inverting the padding highlight in a similar way we do for `thin` code borders. Minor other change, re-order class definitions to be top down.
1 parent c283dec commit b292624

File tree

10 files changed

+510
-467
lines changed

10 files changed

+510
-467
lines changed

Diff for: README.md

+8
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,10 @@ require('render-markdown').setup({
447447
above = '',
448448
-- Used below code blocks for thin border.
449449
below = '',
450+
-- Icon to add to the left of inline code.
451+
inline_left = '',
452+
-- Icon to add to the right of inline code.
453+
inline_right = '',
450454
-- Padding to add to the left & right of inline code.
451455
inline_pad = 0,
452456
-- Highlight for code blocks.
@@ -1005,6 +1009,10 @@ require('render-markdown').setup({
10051009
above = '',
10061010
-- Used below code blocks for thin border.
10071011
below = '',
1012+
-- Icon to add to the left of inline code.
1013+
inline_left = '',
1014+
-- Icon to add to the right of inline code.
1015+
inline_right = '',
10081016
-- Padding to add to the left & right of inline code.
10091017
inline_pad = 0,
10101018
-- Highlight for code blocks.

Diff for: doc/custom-handlers.md

+15-15
Original file line numberDiff line numberDiff line change
@@ -12,30 +12,30 @@ needed, and concealing when the cursor enters.
1212
Each handler must conform to the following interface:
1313

1414
```lua
15-
---@class (exact) render.md.MarkText
16-
---@field [1] string text
17-
---@field [2] string|string[] highlights
18-
19-
---@alias render.md.MarkLine render.md.MarkText[]
15+
---@class (exact) render.md.Handler
16+
---@field extends? boolean
17+
---@field parse fun(ctx: render.md.HandlerContext): render.md.Mark[]
2018

21-
---@class render.md.MarkOpts: vim.api.keyset.set_extmark
22-
---@field virt_text? render.md.MarkLine
23-
---@field virt_text_pos? 'eol'|'inline'|'overlay'
24-
---@field virt_lines? render.md.MarkLine[]
19+
---@class (exact) render.md.HandlerContext
20+
---@field buf integer
21+
---@field root TSNode
2522

2623
---@class (exact) render.md.Mark
2724
---@field conceal boolean
2825
---@field start_row integer
2926
---@field start_col integer
3027
---@field opts render.md.MarkOpts
3128

32-
---@class (exact) render.md.HandlerContext
33-
---@field buf integer
34-
---@field root TSNode
29+
---@class render.md.MarkOpts: vim.api.keyset.set_extmark
30+
---@field virt_text? render.md.MarkLine
31+
---@field virt_text_pos? 'eol'|'inline'|'overlay'
32+
---@field virt_lines? render.md.MarkLine[]
3533

36-
---@class (exact) render.md.Handler
37-
---@field extends? boolean
38-
---@field parse fun(ctx: render.md.HandlerContext): render.md.Mark[]
34+
---@alias render.md.MarkLine render.md.MarkText[]
35+
36+
---@class (exact) render.md.MarkText
37+
---@field [1] string text
38+
---@field [2] string|string[] highlights
3939
```
4040

4141
The `parse` function takes a `ctx` parameter whose fields are:

Diff for: doc/render-markdown.txt

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
*render-markdown.txt* For 0.11.0 Last change: 2025 April 01
1+
*render-markdown.txt* For 0.11.0 Last change: 2025 April 02
22

33
==============================================================================
44
Table of Contents *render-markdown-table-of-contents*
@@ -512,6 +512,10 @@ Default Configuration ~
512512
above = '▄',
513513
-- Used below code blocks for thin border.
514514
below = '▀',
515+
-- Icon to add to the left of inline code.
516+
inline_left = '',
517+
-- Icon to add to the right of inline code.
518+
inline_right = '',
515519
-- Padding to add to the left & right of inline code.
516520
inline_pad = 0,
517521
-- Highlight for code blocks.
@@ -1064,6 +1068,10 @@ Code Block Configuration ~
10641068
above = '▄',
10651069
-- Used below code blocks for thin border.
10661070
below = '▀',
1071+
-- Icon to add to the left of inline code.
1072+
inline_left = '',
1073+
-- Icon to add to the right of inline code.
1074+
inline_right = '',
10671075
-- Padding to add to the left & right of inline code.
10681076
inline_pad = 0,
10691077
-- Highlight for code blocks.

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local state = require('render-markdown.state')
55
local M = {}
66

77
---@private
8-
M.version = '8.2.3'
8+
M.version = '8.2.4'
99

1010
function M.check()
1111
M.start('version')

0 commit comments

Comments
 (0)