Show full ToC entry on hold (#6729)

Fix #6728
This commit is contained in:
NiLuJe
2020-09-30 19:56:56 +02:00
committed by GitHub
parent f0f0cfd167
commit ec3ec8dc21
6 changed files with 48 additions and 8 deletions

View File

@@ -14,7 +14,7 @@ local bor = bit.bor
local util = {}
--- Strips all punctuation marks and spaces from a string.
---- Strips all punctuation marks and spaces from a string.
---- @string text the string to be stripped
---- @treturn string stripped text
function util.stripPunctuation(text)
@@ -24,6 +24,33 @@ function util.stripPunctuation(text)
return text:gsub("\226[\128-\131][\128-\191]", ''):gsub("^%p+", ''):gsub("%p+$", '')
end
-- Various whitespace trimming helpers, from http://lua-users.org/wiki/CommonFunctions & http://lua-users.org/wiki/StringTrim
---- Remove leading whitespace from string.
---- @string s the string to be trimmed
---- @treturn string trimmed text
function util.ltrim(s)
return (s:gsub("^%s*", ""))
end
---- Remove trailing whitespace from string.
---- @string s the string to be trimmed
---- @treturn string trimmed text
function util.rtrim(s)
local n = #s
while n > 0 and s:find("^%s", n) do
n = n - 1
end
return s:sub(1, n)
end
---- Remove leading & trailing whitespace from string.
---- @string s the string to be trimmed
---- @treturn string trimmed text
function util.trim(s)
local from = s:match"^%s*()"
return from > #s and "" or s:match(".*%S", from)
end
--[[--
Splits a string by a pattern