1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Fix default tags

This commit is contained in:
Étienne Fildadut 2022-01-14 21:31:56 +01:00
parent 10af596a58
commit 4214fafc68
2 changed files with 11 additions and 3 deletions

View file

@ -116,7 +116,7 @@ local interpreter_methods = {
return self
end,
--- interrupt the vm on the next step, executing an expression is specified
--- interrupt the vm on the next step, executing an expression if specified
-- returns self
interrupt = function(self, expr)
self.state.interpreter.interrupt = expr or true
@ -511,7 +511,9 @@ local vm_mt = {
-- interrupt
interrupt = nil,
-- tag stack
tags = tags or {},
tags = {},
-- default tags for everything in this interpreter (Lua values)
base_lua_tags = tags,
},
},
vm = self

View file

@ -9,9 +9,15 @@ local function post_process_text(state, text)
local r = {}
-- copy into r & convert tags to lua
for _, t in ipairs(text) do
local tags = common.to_lua(t.tags)
if state.interpreter.base_lua_tags then
for k, v in pairs(state.interpreter.base_lua_tags) do
if tags[k] == nil then tags[k] = v end
end
end
table.insert(r, {
text = t.text,
tags = common.to_lua(t.tags)
tags = tags
})
end
-- remove trailing spaces