Albert,
"Bernardo C. D. A. Vasconcelos" <bernardov...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> writes:
> A filter that seems close enough is the bibexport filter at https://
> raw.githubusercontent.com/pandoc/lua-filters/master/bibexport/
> bibexport.lua which I reproduce below:
Newer pandoc versions allow to shorten this to
```
function Pandoc (doc)
doc.meta.references = pandoc.utils.references(doc)
doc.meta.bibliography = nil
return doc
end
```
Here's a "quick n' dirty" filter that should make your `[@key]{.title}`
syntax work:
```
function Pandoc (doc)
doc.meta.references = pandoc.utils.references(doc)
doc.meta.bibliography = nil
return doc:walk{
Span = function (span)
-- check that the span contains only a single cite object
local cite = span.content[1]
local citations = cite and cite.citations or nil
if #span.content == 1 and cite.t == 'Cite' and #citations == 1 then
local cite_id = citations[1].id
local ref = doc.meta.references:find_if(
function (r) return cite_id == r.id end
)
if ref and span.classes[1] then
-- replace the span with a specific citation field
return ref[span.classes[1]]
end
end
end
}
end
```
It's a bit condensed and not well documented, so let me know if you have
questions.
--
Albert Krewinkel
GPG: 8eed e3e2 e8c5 6f18 81fe e836 388d c0b2 1f63 1124