mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-27 08:39:30 +00:00
[api] allow text event data grouping by tag
This commit is contained in:
parent
2a7e1a4be5
commit
a3dded3935
7 changed files with 140 additions and 23 deletions
45
test/results/text grouping.ans
Normal file
45
test/results/text grouping.ans
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
--# run #--
|
||||
--- text ---
|
||||
| {}"A" |
|
||||
| {}"A" |
|
||||
| {}"A" |
|
||||
--- text ---
|
||||
| {"group":1}"B" |
|
||||
| {"group":1}"B" |
|
||||
| {"group":1}"B" |
|
||||
--- text ---
|
||||
:: group ::
|
||||
| {"group":1}"C" |
|
||||
| {"group":1}"C" |
|
||||
:: group ::
|
||||
| {"group":3}"D" |
|
||||
--- text ---
|
||||
:: group ::
|
||||
| {"group":1}"E" |
|
||||
:: group ::
|
||||
| {"group":"j"}"F" |
|
||||
:: group ::
|
||||
| {"group":1}"G" |
|
||||
--- text ---
|
||||
:: group ::
|
||||
| {"group":1}"H" |
|
||||
:: group ::
|
||||
| {}"I" |
|
||||
:: group ::
|
||||
| {"group":1}"J" |
|
||||
--- text ---
|
||||
:: group ::
|
||||
| {"group":1}"K" |
|
||||
:: group ::
|
||||
| {}"L" |
|
||||
| {"not group":1}"L" |
|
||||
--- text ---
|
||||
:: group ::
|
||||
| {}"M" |
|
||||
:: group ::
|
||||
| {"group":"j"}"N" |
|
||||
| {"group":"j"}"N" |
|
||||
--- return ---
|
||||
()
|
||||
--# saved #--
|
||||
{}
|
||||
|
|
@ -33,8 +33,13 @@ local function run_loop(run_state, write_output, interactive)
|
|||
local e, data = run_state:step()
|
||||
write_output("--- "..e.." ---")
|
||||
if e == "text" then
|
||||
for _, l in ipairs(data) do
|
||||
write_output(l:format(run_state))
|
||||
local grouped = data:group_by("group")
|
||||
local groups = #grouped > 1
|
||||
for _, v in ipairs(grouped) do
|
||||
if groups then write_output(":: group ::") end
|
||||
for _, l in ipairs(v) do
|
||||
write_output(l:format(run_state))
|
||||
end
|
||||
end
|
||||
elseif e == "choice" then
|
||||
local choice
|
||||
|
|
|
|||
39
test/tests/text grouping.ans
Normal file
39
test/tests/text grouping.ans
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
| A
|
||||
| A
|
||||
| A
|
||||
|
||||
"group": 1 #
|
||||
| B
|
||||
| B
|
||||
| B
|
||||
|
||||
"group": 1 #
|
||||
| C
|
||||
"group": 1 #
|
||||
| C
|
||||
"group": 3 #
|
||||
| D
|
||||
|
||||
"group": 1 #
|
||||
| E
|
||||
"group": "j" #
|
||||
| F
|
||||
"group": 1 #
|
||||
| G
|
||||
|
||||
"group": 1 #
|
||||
| H
|
||||
| I
|
||||
"group": 1 #
|
||||
| J
|
||||
|
||||
"group": 1 #
|
||||
| K
|
||||
| L
|
||||
"not group": 1 #
|
||||
| L
|
||||
|
||||
| M
|
||||
"group": "j" #
|
||||
| N
|
||||
| N
|
||||
Loading…
Add table
Add a link
Reference in a new issue