Hi,
I use this lua filter to move references after a special heading to the document metadata :
```lua
-- local pprint = require('pprint')
references = {}
function getRefsFromDiv (div)
if div.identifier == 'literatur' then
pandoc.walk_block(div, {
Para = function(el)
table.insert(references, el.content)
end})
return {} -- remove from main body
end
end
function addRefsToMeta (meta)
if not next(references) then
return meta
else
meta.biblio = references
if not meta.bibliotitle then
if pandoc.utils.stringify(meta['lang']) == 'en' then
meta.bibliotitle = "References"
else
meta.bibliotitle = "Literatur"
end
end
-- pprint(references)
return meta
end
end
function put_in_divs(doc)
local blocks = {}
for i,el in pairs(doc.blocks) do
table.insert(blocks, el)
end
local newblocks = pandoc.utils.make_sections(nil, 1, blocks)
return pandoc.Pandoc(newblocks, doc.meta)
end
function flatten_divs(div)
if div.classes[1] == 'section' then
return div.content
end
end
return {
{ Pandoc = put_in_divs },
{ Div = getRefsFromDiv },
{ Meta = addRefsToMeta },
{ Div = flatten_divs},
}
```
The filter works, but it has the side effect that it also removes all section ids.
Input:
```md
---
lang: en
---
# Introduction
Bla Bla
Bla Bla
# Bibliography {#literatur}
Test Test
Test Test
```
pandoc input.md
```
<h1 id="introduction">Introduction</h1>
<p>Bla Bla</p>
<p>Bla Bla</p>
<h1 id="literatur">Bibliography</h1>
<p>Test Test</p>
<p>Test Test</p>```
pandoc input.md -L heading-refs-to-meta.lua
```
<h1>Introduction</h1>
<p>Bla Bla</p>
<p>Bla Bla</p>
```
Any ideas how I can preserve the ids?
Best,
Denis