inukshuk / citeproc-ruby

A Citation Style Language (CSL) Cite Processor
101 stars 22 forks source link

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

Open retorquere opened 5 years ago

retorquere commented 5 years ago

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?

inukshuk commented 5 years ago

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).

retorquere commented 5 years ago

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

inukshuk commented 5 years ago

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).

retorquere commented 5 years ago

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 commented 5 years ago

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.

inukshuk commented 5 years ago

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.

retorquere commented 5 years ago

That will work just fine - thanks!