citeproc-ruby icon indicating copy to clipboard operation
citeproc-ruby copied to clipboard

Can I bring in my own styles rather than require-ing csl/styles?

Open retorquere opened this issue 6 years ago • 7 comments

I am looking to use the ruby citeproc gems to test styles that are not in csl/styles -- how would I feed the style to the processor in this case?

retorquere avatar May 09 '19 09:05 retorquere

You can load a style by passing an absolute path or URL instead of the name, or, if you would like to be able to load the styles via short names you can set the style/locale roots to the folder where you keep the styles.

The csl-styles gem does nothing but this -- setting the root folders to its own styles/locales folders (which are just pulled from the CSL repositories).

inukshuk avatar May 09 '19 09:05 inukshuk

And if I pass it an url, it will download the style? Awesome, that actually solves a different problem immediately.

retorquere avatar May 09 '19 09:05 retorquere

Yes, if I remember correctly it should download the style. By the way, here's the test setup from the official styles repo -- that might be helpful as well.

Generally, you should try to load styles only once if you process many items over time (regardless of whether you load from the file system or via URL, parsing the style takes more time than rendering citations usually).

inukshuk avatar May 09 '19 09:05 inukshuk

smacks forehead I was rummaging around there and it didn't dawn upon me that they were using this gem. This is going to prevent a slew of questions I was about to ask. Thanks!

retorquere avatar May 09 '19 09:05 retorquere

When I pass an URL, is there a way for me to add custom headers? I need to pull a file from the github API. I could store it in a temp file, but if it's not required, that'd be preferable.

retorquere avatar May 16 '19 20:05 retorquere

No, I'm afraid there's no way to do that at the moment. You can however, pass the contents of the CSL instead of a path, so you won't need to create a temp file.

inukshuk avatar May 17 '19 08:05 inukshuk

That will work just fine - thanks!

retorquere avatar May 17 '19 09:05 retorquere