Skip to content

Commit 1343acc

Browse files
authored
fix(lsp): allow whitespace info string in markdown (#535)
1 parent 6c87c1d commit 1343acc

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

lua/noice/text/markdown.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ function M.parse(text, opts)
9292
end
9393
elseif M.is_code_block(line) then
9494
---@type string
95-
local lang = line:match("```(%S+)") or opts.ft or "text"
95+
local lang = line:match("```%s*(%S+)") or opts.ft or "text"
9696
local block = { lang = lang, code = {} }
9797
while lines[l + 1] and not M.is_code_block(lines[l + 1]) do
9898
table.insert(block.code, lines[l + 1])

tests/text/markdown_spec.lua

+19-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ local b
131131
{
132132
input = [[
133133
134-
***
134+
***
135135
136136
```lua
137137
local a
@@ -149,6 +149,24 @@ local a
149149
{
150150
input = [[
151151
152+
***
153+
154+
``` lua
155+
local a
156+
```
157+
158+
---
159+
160+
]],
161+
output = {
162+
{ line = "---" },
163+
{ code = { "local a" }, lang = "lua" },
164+
{ line = "---" },
165+
},
166+
},
167+
{
168+
input = [[
169+
152170
```lua
153171
local a
154172
```

0 commit comments

Comments
 (0)