inukshuk / jekyll-scholar

jekyll extensions for the blogging scholar
MIT License
1.12k stars 102 forks source link

Multiple Anchors for Multiple Citations #288

Open bradyneal opened 4 years ago

bradyneal commented 4 years ago

According to the multiple citation part of the README, {% cite ruby microscope %} is supposed to turn into a single anchor: <a href="#ruby">(Flanagan &amp; Matsumoto 2008; Shaughnessy 2013)</a>

Is there a way to get it to produce multiple anchors, so that if the reader clicks on any one, they will be directed to the correct reference in the bibliography, rather than the first one in the cite? For example, the behavior I'm used to with LateX's natbib would produce something like the following: (<a href="#ruby">Flanagan &amp; Matsumoto 2008</a>; <a href="#microscope">Shaughnessy 2013</a>)

inukshuk commented 4 years ago

Unfortunately there's no easy way to do this at the moment. The reason is that the citation is processed by citeproc using your CSL style. jekyll-scholar adds the link around the full citation later on. This is because the CSL style has pretty much full control over how to render multiple citations.

The workaround I can think of is to alter your CSL style to omit the parentheses and render two citations using this alternate style, adding parens and semicolon manually. Obviously that's not a satisfying solution but while there's no easy way to hook into the citation processing from outside there's not really a better way.

Another option that might work better but is contingent on knowledge about your citation style is to monkey patch jekyll-scholars cite function. The link is generated around here -- it would not be too difficult to post-process the rendered citation, breaking it up into individual citations based on what you know about your style (e.g., if more than one entry was rendered, split the string inside the parens based on a suitable pattern and link-up each citation individually.