jgm / pandoc-citeproc

Library and executable for using citeproc with pandoc
BSD 3-Clause "New" or "Revised" License
291 stars 61 forks source link

[feature] Extracting citations #453

Closed mbojan closed 4 years ago

mbojan commented 4 years ago

I'd love to see an option to pandoc-citeproc that will allow for extracting citation keys used in the Markdown document. It is not that straightforward to do so with regular expressions as one has make sure no false positive (e.g. use of @ within code blocks) will be picked up. On the other hand I imagine you already have the code that identifies only the relevant @citationkeys.

Apologies for not being more specific or constructive but I'm a Haskell-agnostic.

I will be obviously extremely grateful for suggestions if the goal above can be easily achieved using some existing tools/options.

denismaier commented 4 years ago

You can probably use a lua filter for that... I can't look into this at the moment. But if you ask on pandoc-discuss you'll most likely get helpful answers.

tarleb commented 4 years ago

There is the bibexport filter, which collects the IDs as part of its operation. It shouldn't be too difficult to shorten it to just output the ID's.

nathanlesage commented 4 years ago

If you don't mind using node (or want to port that logic to LUA), have a look at https://github.com/Zettlr/Citr — it includes a method precisely for extracting Pandoc-compatible citekeys

mbojan commented 4 years ago

Thank you all for all the pointers. I saw some third-party tools but I was not trustful enough and thought of something closer to pandoc. I'll definitely have look at the lua filter. Thanks!