summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenny Shields <mail@kennyshields.net>2016-07-09 20:36:49 -0400
committerKenny Shields <mail@kennyshields.net>2016-07-09 20:36:49 -0400
commit1ad9a32db97900272e6b6c0337d63500d42ca41a (patch)
treead1747161e037f882964398eefc7f460ce93d689
parent42af94a8a7e375f5ffdcc468fcefd5b74d0a0b69 (diff)
downloadstp-1ad9a32db97900272e6b6c0337d63500d42ca41a.tar.gz
stp-1ad9a32db97900272e6b6c0337d63500d42ca41a.zip
Allow multiple sub tokens of the same name
-rw-r--r--init.lua12
1 files changed, 8 insertions, 4 deletions
diff --git a/init.lua b/init.lua
index 4f30375..446aa09 100644
--- a/init.lua
+++ b/init.lua
@@ -89,18 +89,18 @@ local function checkNamed(str)
for match in str:gmatch(pattern) do
-- add the named items to the sub token table
local name, contents = match:match(pattern:sub(2, -2))
- token_table[token_current][name] = contents
+ token_table[token_current][#token_table[token_current]][name] = contents
end
-- remove all named items from the string
str = trim(str:gsub(pattern, ""))
-- append any remaining text to the sub token's default string
- local text = token_table[token_current]._default
+ local text = token_table[token_current][#token_table[token_current]]._default
if text ~= "" then
str = " " .. str
end
- token_table[token_current]._default = text .. str
+ token_table[token_current][#token_table[token_current]]._default = text .. str
end
@@ -132,7 +132,11 @@ local function parseLine(line)
else
-- create table for sub token and check the line string for any
-- named items
- token_table[token_current] = {_default = ""}
+ if not token_table[token_current] then
+ token_table[token_current] = {{_default = ""}}
+ else
+ table.insert(token_table[token_current], {_default = ""})
+ end
checkNamed(line)
end
end