-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get list of references in Lua filter #7752
Comments
Could you clarify why you want this?/what you'd be able to do with it that you can't do now? |
I'm trying to generate Crossref XML output. The XML should include information on all citations in an article, which I'd like to generate in a filter (or maybe in a custom writer). I don't see a clean solution to do this right now. |
|
Quite likely, yes. I guess I had assumed that I'd do some hacky back-and-forth through JSON to get the output I need. The main thing that gave me pause was that keys in the Reference variables map are case-insensitive, which doesn't fit into the HsLua object framework. But if we ignore this, then there would be only two other values that'd need to be marshaled, |
Can you make keys case-insensitive using metatables, e.g. https://nachtimwald.com/2019/02/12/lua-case-insenstive-table/ ? |
The problem I saw is that this kind of table requires low-level code and doesn't fit the However, I now think special handling is justified in this case: for one thing, it will enable the case-insensitive handling. Another point is that users may want to use the References list as metadata, which is easy to support if a Long story short: Using a normal table/metatable combination for Reference values is likely the best choice. Thanks for asking the right questions! Maybe JSON support could still be interesting, but that's a different topic. |
List with all cited references of a document. Closes: jgm#7752
List with all cited references of a document. Closes: #7752
I'd like to get the list of references for a document, essentially by exposing the function
T.P.Citeproc.getReferences
to Lua. Here's what I think would be a good way to approach this. The basic idea is to improve JSON support in filters, soReference
values can be opaque objects for now.tojson
is added to the pandoc.utils module (or maybe a separatepandoc.json
module?). The function uses aeson to do the encoding.tostring
function, thetojson
function checks for a__tojson
metamethod and returns the result of that function if it exists.__tojson
metamethod is added to all AST elements that are instances ofToJSON
.Reference
type is added to Lua; it has no properties except for the__tostring
, and__tojson
metamethods.getReferences
function is exported aspandoc.utils.references
.This would give access to references without us having to decide which Reference properties to expose, and how to bring case-insensitive behavior to Lua. Also, having
tojson
seems like a generally useful feature.Does it sound like a sensible course of action?
Edit: There'd also be a function
fromjson
which converts a JSON string to a Lua object. It could take an optional second parameter to identify the target type. E.g.,fromjson(input, pandoc.ReaderOptions)
The text was updated successfully, but these errors were encountered: