summaryrefslogtreecommitdiff
path: root/paper/lua-filters/abstract-to-meta/abstract-to-meta.lua
blob: dbf9b03105ea0cb3c707cb064b9e1fcdfc36d68c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
local looking_at_abstract = false
local abstract = {}

function Block (elem)
  if looking_at_abstract then
    abstract[#abstract + 1] = elem
    return {}
  end
end

function Header (elem)
  if elem.level == 1 and elem.identifier == 'abstract' then
    looking_at_abstract = true
    return {}
  else
    looking_at_abstract = looking_at_abstract and elem.level ~= 1
  end
end

function Meta (meta)
  meta.abstract = meta.abstract or pandoc.MetaBlocks(abstract)
  return meta
end