refactor: use the variables in more places

This commit is contained in:
Oliver Davies 2022-08-09 00:43:18 -04:00
parent acf32d44b0
commit a3fabd8fa4

View file

@ -1,21 +1,21 @@
local checked_character = "x"
local checked_checkbox = "[" .. checked_character .. "]"
local checked_checkbox = "%[" .. checked_character .. "%]"
local unchecked_checkbox = "%[ %]"
local line_contains_an_unchecked_checkbox = function(line)
return string.find(line, unchecked_checkbox)
end
local checkbox = {}
local checkbox = {
check = function(line)
return line:gsub(unchecked_checkbox, checked_checkbox)
end,
checkbox.check = function(line)
return line:gsub("%[ %]", checked_checkbox)
end
checkbox.uncheck = function(line)
return line:gsub("%[" .. checked_character .. "%]", unchecked_checkbox)
end
uncheck = function(line)
return line:gsub(checked_checkbox, unchecked_checkbox)
end,
}
local M = {}