diff --git a/lua/toggle-checkbox.lua b/lua/toggle-checkbox.lua index 4ae54e8..03714a7 100644 --- a/lua/toggle-checkbox.lua +++ b/lua/toggle-checkbox.lua @@ -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 = {}