presser.nvim/presser/utils.lua
TheOnePath 3724426d33 Renamed modules
Files were moved from top-level space into presser sub-directory.
2023-01-13 17:18:56 +00:00

41 lines
815 B
Lua

local M = {}
M.iter_table_dump = function ( arr )
for k, v in pairs(arr) do
print("Table:", k, v)
end
end
local escape_chars = function ( text )
return string.gsub(text, "[%(|%)|\\|%[|%]|%-|%{%}|%?|%+|%*|%^|%$|%.]", {
["\\"] = "\\\\",
["-"] = "\\-",
["("] = "\\(",
[")"] = "\\)",
["["] = "\\[",
["]"] = "\\]",
["{"] = "\\{",
["}"] = "\\}",
["?"] = "\\?",
["+"] = "\\+",
["*"] = "\\*",
["^"] = "\\^",
["$"] = "\\$",
["."] = "\\.",
})
end
-- :@dev: clean the text once it has been fetched from buffer
M.clean_buf = function ( text )
if not type(text) == "string" or text == nil then
print("[DEBUG - clean_buf] Given input is not of type string.")
return
end
return escape_chars( text )
:match( "^%s*(.-)%s*$" )
end
return M