diff options
| author | rxi <rxi@users.noreply.github.com> | 2020-05-07 10:27:37 +0100 |
|---|---|---|
| committer | rxi <rxi@users.noreply.github.com> | 2020-05-07 10:27:37 +0100 |
| commit | 3057786ce2bbd8cc623e1597718c200945cc6d82 (patch) | |
| tree | a7a686aee774326b2ef737d0aff71562f9515d6e /data/core/syntax.lua | |
| parent | e551052e9102ce02ff4f3a55c5e1af4f001cc585 (diff) | |
| download | pragtical-3057786ce2bbd8cc623e1597718c200945cc6d82.tar.gz pragtical-3057786ce2bbd8cc623e1597718c200945cc6d82.zip | |
Moved `matches_pattern` from `syntax` to `common`
Diffstat (limited to 'data/core/syntax.lua')
| -rw-r--r-- | data/core/syntax.lua | 16 |
1 files changed, 3 insertions, 13 deletions
diff --git a/data/core/syntax.lua b/data/core/syntax.lua index 08db473c..ddc1b2f2 100644 --- a/data/core/syntax.lua +++ b/data/core/syntax.lua @@ -1,21 +1,11 @@ -local syntax = {} +local common = require "core.common" +local syntax = {} syntax.items = {} local plain_text_syntax = { patterns = {}, symbols = {} } -local function matches_pattern(text, pattern) - if type(pattern) == "string" then - return text:find(pattern) - end - for _, p in ipairs(pattern) do - if matches_pattern(text, p) then return true end - end - return false -end - - function syntax.add(t) table.insert(syntax.items, t) end @@ -24,7 +14,7 @@ end function syntax.get(filename) for i = #syntax.items, 1, -1 do local t = syntax.items[i] - if matches_pattern(filename, t.files) then + if common.matches_pattern(filename, t.files) then return t end end |
