-
Notifications
You must be signed in to change notification settings - Fork 42
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
Manubot cite: ability to output formatted bibliography #48
Comments
Yes, maybe! It sounds better than making temporary files, but we ought to check out the non-compatible things and see if they're relevant.
Not sure about that, but maybe. A two minute search didn't come up with anything relevant. |
Another option would be to use the JavaScript parser and call it from python using something like https://github.com/stefano/pyduktape. |
Paging the pros @rmzelle @jgm @Juris-M @brechtm: We are looking to convert CSL JSON Data to a formatted bibliography from a Python program. Basically we're creating a command-line interface where a user would type:
Then the program would output something like:
Any idea what the best solution is that can combine CSL JSON Data + CSL XML Style and output a bibliography? Note we don't actually care about rendering the citations in the text, just the reference list. |
If you wanted to use pandoc (and pandoc-citeproc) for this, you could.
Pandoc will accept a bibliography in CSL JSON format or in bibtex format (which you might more easily get from online services)
A pandoc markdown document containing just
# ---
nocite: '@*'
bibliography: yourbib.bib
csl: yourcsl.csl
...
will generate citations for everything in the bibliography. (Note that you need to use `--filter pandoc-citeproc` on the command line.) With pandoc you can get the output in many different formats, including 'plain'.
Your only tasks would be:
(1) generating the bibliography from the arguments to your cli program, and
(2) stripping out the bibliography part of pandoc's output (since you don't want the citations themselves). This can be done easily using a pandoc filter or lua-filter.
|
For a Python project, citeproc-py would indeed be the obvious choice, of course. It should handle your use case just fine. There is no documentation, but you can basically copy the code from the examples. Note that citeproc-py does depend on libxml, if you are concerned about non-pure-Python dependencies. Removing that dependency (citeproc-py/citeproc-py#35) has been suggested, but unlikely to materialize any time soon since I don't have time to work on citeproc-py and no one has stepped up as a maintainer. This also means that development has stagnated. Considering that, it may be wiser to choose pandoc. But since your implementation will just be a few lines of code, there's little risk involved. |
* Update for expanded manubot package * Create distinct caching directory * Deployment: references branch now output * Rewrite documentation * Rename CONTRIBUTING.md to USAGE.md Refs manubot#2
Suggested by @slochower in #42 (comment):
Brilliant! I agree this would be super useful, for cases ranging prototyping to just wanted to generate a reference.
One option would be to use citeproc-py. I am also guessing there is a pandoc / pandoc-citeproc solution that is more direct than having to mess with creating a source markdown file. However, that would create a non-python dependency, which may be difficult for many casual users.
The text was updated successfully, but these errors were encountered: