Skip to content

Commit

Permalink
fix(lsp): allow whitespace info string in markdown (#535)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikesmithgh authored Jul 16, 2023
1 parent 6c87c1d commit 1343acc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lua/noice/text/markdown.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ function M.parse(text, opts)
end
elseif M.is_code_block(line) then
---@type string
local lang = line:match("```(%S+)") or opts.ft or "text"
local lang = line:match("```%s*(%S+)") or opts.ft or "text"
local block = { lang = lang, code = {} }
while lines[l + 1] and not M.is_code_block(lines[l + 1]) do
table.insert(block.code, lines[l + 1])
Expand Down
20 changes: 19 additions & 1 deletion tests/text/markdown_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ local b
{
input = [[
***
***
```lua
local a
Expand All @@ -149,6 +149,24 @@ local a
{
input = [[
***
``` lua
local a
```
---
]],
output = {
{ line = "---" },
{ code = { "local a" }, lang = "lua" },
{ line = "---" },
},
},
{
input = [[
```lua
local a
```
Expand Down

0 comments on commit 1343acc

Please sign in to comment.