-
Hi, I’m making a filter for revealJS presentations and I’m struggling with modifying attributes of block elements. Actually (this is just a portion of my code that I think is sufficient to understand my question, but if needed I can post the full code or even the AST), I don’t understand why this works (ie the background becomes blue): local function bblocks (blocks)
local figuretype
-- Go from end to start to avoid problems with shifting indices.
for i = #blocks-1, 1, -1 do
figuretype = is_figure_in_fullframegraphic_frame(blocks[i], blocks[i+1])
if figuretype == "Figure" then
blocks[i].attributes.style = "background-color: blue"
elseif figuretype == "Para" then
print("Para")
end
end
return blocks
end But that doesn’t (note the line with background-image, error below): local function bblocks (blocks)
local figuretype
-- Go from end to start to avoid problems with shifting indices.
for i = #blocks-1, 1, -1 do
figuretype = is_figure_in_fullframegraphic_frame(blocks[i], blocks[i+1])
if figuretype == "Figure" then
blocks[i].attributes.background-image = "img.jpg"
elseif figuretype == "Para" then
print("Para")
end
end
return blocks
end Error:
Thanks for the help! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Lua allows to use
Thus, blocks[i].attributes['background-image'] = "img.jpg" |
Beta Was this translation helpful? Give feedback.
Lua allows to use
my_table.key
as an alias formy_table['key']
, i.e., it lookskey
up in tablemy_table
. However, this works only if the key is a Name, which the Lua manual defines like this:Thus,
background-image
is not a name, which means that square brackets have to be used: