Fix luadoc for escape/unescape. Add docs for getdir.
Signed-off-by: Julien Danjou <julien@danjou.info>
This commit is contained in:
parent
06bc2a2e37
commit
77d6562e02
|
@ -90,20 +90,19 @@ function eval(s)
|
||||||
return assert(loadstring("return " .. s))()
|
return assert(loadstring("return " .. s))()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local xml_entity_names = { ["'"] = "'", ["\""] = """, ["<"] = "<", [">"] = ">", ["&"] = "&" };
|
||||||
--- Escape a string from XML char.
|
--- Escape a string from XML char.
|
||||||
-- Useful to set raw text in textbox.
|
-- Useful to set raw text in textbox.
|
||||||
-- @param text Text to escape.
|
-- @param text Text to escape.
|
||||||
-- @return Escape text.
|
-- @return Escape text.
|
||||||
local xml_entity_names = { ["'"] = "'", ["\""] = """, ["<"] = "<", [">"] = ">", ["&"] = "&" };
|
|
||||||
function escape(text)
|
function escape(text)
|
||||||
return text and text:gsub("['&<>\"]", xml_entity_names) or nil
|
return text and text:gsub("['&<>\"]", xml_entity_names) or nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local xml_entity_chars = { lt = "<", gt = ">", nbsp = " ", quot = "\"", apos = "'", ndash = "-", mdash = "-", amp = "&" };
|
||||||
--- Unescape a string from entities.
|
--- Unescape a string from entities.
|
||||||
-- @param text Text to unescape.
|
-- @param text Text to unescape.
|
||||||
-- @return Unescaped text.
|
-- @return Unescaped text.
|
||||||
|
|
||||||
local xml_entity_chars = { lt = "<", gt = ">", nbsp = " ", quot = "\"", apos = "'", ndash = "-", mdash = "-", amp = "&" };
|
|
||||||
function unescape(text)
|
function unescape(text)
|
||||||
return text and text:gsub("&(%a+);", xml_entity_chars) or nil
|
return text and text:gsub("&(%a+);", xml_entity_chars) or nil
|
||||||
end
|
end
|
||||||
|
@ -134,6 +133,11 @@ function restart()
|
||||||
capi.awesome.restart()
|
capi.awesome.restart()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Get the user's config or cache dir.
|
||||||
|
-- It first checks XDG_CONFIG_HOME / XDG_CACHE_HOME, but then goes with the
|
||||||
|
-- default paths.
|
||||||
|
-- @param d The directory to get (either "config" or "cache").
|
||||||
|
-- @return A string containing the requested path.
|
||||||
function getdir(d)
|
function getdir(d)
|
||||||
if d == "config" then
|
if d == "config" then
|
||||||
local dir = os.getenv("XDG_CONFIG_HOME")
|
local dir = os.getenv("XDG_CONFIG_HOME")
|
||||||
|
|
Loading…
Reference in New Issue