aboutsummaryrefslogtreecommitdiff
path: root/scripts/text_utils.lua
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
committerJosh Rahm <joshuarahm@gmail.com>2024-05-24 19:18:11 +0000
commitff7ed8f586589d620a806c3758fac4a47a8e7e15 (patch)
tree729bbcb92231538fa61dab6c3d890b025484b7f5 /scripts/text_utils.lua
parent376914f419eb08fdf4c1a63a77e1f035898a0f10 (diff)
parent28c04948a1c887a1cc0cb64de79fa32631700466 (diff)
downloadrneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.gz
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.tar.bz2
rneovim-ff7ed8f586589d620a806c3758fac4a47a8e7e15.zip
Merge remote-tracking branch 'upstream/master' into mix_20240309
Diffstat (limited to 'scripts/text_utils.lua')
-rw-r--r--scripts/text_utils.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/scripts/text_utils.lua b/scripts/text_utils.lua
index 937408c546..75b3bfedd5 100644
--- a/scripts/text_utils.lua
+++ b/scripts/text_utils.lua
@@ -318,7 +318,7 @@ local function align_tags(text_width)
--- @param line string
--- @return string
return function(line)
- local tag_pat = '%s+(%*[^ ]+%*)%s*$'
+ local tag_pat = '%s*(%*.+%*)%s*$'
local tags = {}
for m in line:gmatch(tag_pat) do
table.insert(tags, m)
@@ -327,7 +327,9 @@ local function align_tags(text_width)
if #tags > 0 then
line = line:gsub(tag_pat, '')
local tags_str = ' ' .. table.concat(tags, ' ')
- local pad = string.rep(' ', text_width - #line - #tags_str)
+ --- @type integer
+ local conceal_offset = select(2, tags_str:gsub('%*', '')) - 2
+ local pad = string.rep(' ', text_width - #line - #tags_str + conceal_offset)
return line .. pad .. tags_str
end
@@ -352,7 +354,7 @@ function M.md_to_vimdoc(text, start_indent, indent, text_width, is_list)
local s = table.concat(lines, '\n')
-- Reduce whitespace in code-blocks
- s = s:gsub('\n+%s*>([a-z]+)\n?\n', ' >%1\n')
+ s = s:gsub('\n+%s*>([a-z]+)\n', ' >%1\n')
s = s:gsub('\n+%s*>\n?\n', ' >\n')
return s