Skip to content

Building meta array in Lua to iterate in template #10254

Closed Answered by lifeunleaded
lifeunleaded asked this question in Q&A
Discussion options

You must be logged in to vote

Having written the question, I realized the answer: index the table as a 1-indexed array, not with arbitrary identifiers.

meta['sections'] = {}
  i = 1
  for metakey in pairs(section_identifiers) do
    print('metakey', metakey)
    metakey = stringify(metakey)
    local section = collected[metakey]
    if section and #section > 0 then
      meta['sections'][i] = pandoc.MetaBlocks(section)
      i = i + 1
    end
  end

This gives me correct results when using $for$ in the template.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tarleb
Comment options

Answer selected by lifeunleaded
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants