Skip to content
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

Stdio mode #13

Open
cormacrelf opened this issue Nov 4, 2019 · 3 comments
Open

Stdio mode #13

cormacrelf opened this issue Nov 4, 2019 · 3 comments

Comments

@cormacrelf
Copy link
Collaborator

It might turn out to be useful to have a command-line program that runs a citeproc server over stdin/stout with JSON messages. This might be easier to integrate in some applications than a WebAssembly runtime. citeproc-java, for instance, could do this, but so could a Vim plugin. It could also be a neat solution to running inside a Pandoc Lua script.

Stdio has proved a fitting transport for the Language Server Protocol, partly because of this ease of integration. You also wouldn't need to worry about ensuring downstream WebAssembly runtimes actually have the features you need; just build for x86 with rayon parallelism, set up filesystem watchers when requested, etc.

@iandol
Copy link

iandol commented Nov 27, 2021

Hi Cormac, what is the current availability of this method? There is a writing app called Scrivener (written in objective-c for macOS) for which I asked to add support for CSL, but the developer was not convinced of the best way to integrate. Pandoc's newer citeproc has a binary that can communicate via JSON: https://github.com/jgm/citeproc/blob/master/man/citeproc.1.md — I'm not sure as a non-developer of the relative merits of each system.

@cormacrelf
Copy link
Collaborator Author

@iandol citeproc-rs now has bindings for Swift. Swift code can't be used 100% directly in Objective-C, but you can write that part of your app in Swift and expose @objc APIs to the rest of your program. It's available at https://github.com/cormacrelf/CiteprocRsKit, with documentation viewable on the web at https://citeprocrskit.cormacrelf.net/documentation/CiteprocRsKit

On the relative merits, whatever works works. But I would note that:

  • Pandoc citeproc's JSON mode appears to be designed for batch processing, i.e. the whole document at once.
  • citeproc-rs is designed to sit over your shoulder and format all your cites as you go, which is more conducive to live editing with previews.

There's nothing stopping you from implementing either scheme (batch vs incremental) in terms of the other. For citeproc-rs, it's about 20 lines of straightforward code (like this test case) to batch all your cites together for e.g. previewing a full document, or exporting it.

@iandol
Copy link

iandol commented Nov 28, 2021

Thank you, I'll relay this information back to the Scrivener developer. Batch mode will be more useful in this case, so thank you for the sample code for that!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants