timlrx / rehype-citation

Rehype plugin to add citation and bibliography from bibtex files
https://rehype-citation.netlify.app
MIT License
38 stars 7 forks source link

Links and backlinks to the references list #13

Closed activatedgeek closed 1 year ago

activatedgeek commented 1 year ago

For the markdown input:

My markdown text [@Nash1950]

can we have links to the references list and backlinks to the text, and an unordered list as:

<div>My markdown text (<a href="citation--nash1950">Nash, 1950</a>)</div>
<div id="refs" class="references csl-bib-body">
  <ul>
    <li  class="csl-entry" id="bib-nash1950">Nash, J. (1950). Equilibrium points in n-person games.
    <i>Proceedings of the National Academy of Sciences</i>, <i>36</i>(1), 48–49.  [↩](#citation--nash1950) </li>
  </ul>
</div>

Thank you for the great plugin!

timlrx commented 1 year ago

Hi, as mentioned in the readme link-citations is not implemented. The single citation case should be fairly easy to handle but other cases are fairly complicated and the requirements potentially differ by citation style. For example [@Nash1950; @Nash1951] would give:

<span class="" id="citation--nash1950--nash1951--1">(Nash, 1950, 1951)</span>

In this case, it's not quite clear cut how to break up the citation entry and link it to the references entries. Would probably require a deeper look into how pandoc does it.

Happy to accept a PR over here if anyone wants to try implementing it!

timlrx commented 1 year ago

@activatedgeek, I added support for link-citations. It's on the feat/link-citation branch if you want to give it a try. Similar to pandoc it would work for numeric and author-date styles.

Backlinks do not really make that much sense since there can be multiple citations to one bibliography entry. Maybe you are looking for a footnote style citation? You can try chicago-fullnote-bibliography. There's a demo available on the new website as well: https://rehype-citation.netlify.app

activatedgeek commented 1 year ago

Awesome! Thank you so much! I think even one-way link is enough!