Giter Club home page Giter Club logo

mdbook-bib's Introduction

mdbook-bib

A mdBook plugin for creating a bibliography & citations in your books.

Test status MPL-2.0 License Manual

Crate Crates.io

Features

  • Add citations from your BibLaText files
  • Automatically download your public bibliography from Zotero and cite it
  • Allows defining a template for the citations shown in the references page

Basic Install

If you have mdbook installed just do:

cargo install mdbook-bib

Make sure your PATH env var contains Cargo's /bin directory where the plugin was installed. Then follow the instructions below to use the plugin.

See all options in the Install section of the manual.

Add a BibLaTex File and Cite your Bib Entries!

Add a bibliography file in BibLaTex format to the root of your mdbook (which is pointed by the src parameter in the [book] section of the .toml file) and then add the following section to the mdbook's .toml config file:

[book]
#...
[preprocessor.bib]
bibliography = "my_biblio.bib"

The bibliography will appear as a separate section in your book ToC.

Now you can add references/citations to the citation-keys appearing in the .bib file with:

{{#cite my-citation-key}}

or simply with:

@@my-citation-key

See other configuration options in the Config section of the manual.

Contribute

Check the Contrib section of the manual if you want to contribute to mdbook-bib!

mdbook-bib's People

Contributors

francisco-perez-sorrosal avatar mlange-42 avatar raspofabs avatar tchernobog avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

mdbook-bib's Issues

Inline citation styles

Currently, references appear in the text as the key used in the bibtex file. It would be nice to have citation styles like [1] or Author [et al] 2023.

Not sure if using handlebars templates here too is the best, or to just provide a few hard-coded common styles.

Custom reference styles

Would it be an option to provide a default reference formatting style like the one we currently have, and in addition allow for a custom .hbs file in the configuration?

This way, there is no need to focus on a one-fits-all style. Default to something familiar and convenient (like the current style), and possibly provide .hbs files of common stlyes for download.

Citations from sub-directory link to wrong bibliography.html

When citing in a file that is in a sub-directory of the book sources, the same sub-directory is assumed for the linked bibliography.html file, while the file is actually not in that directory.

Example project struture:

root
  |-- src
  |     |-- chapter-1
  |     |     `-- section-1-1.md
  |     |-- bibliography.bib
  |     `-- SUMMARY.md
  `-- book.toml

When citing in section-1-1.md, citations link to chapter-1/bibliography.bib, but should link to bibliography.bib only.

[Feature] Option to show only cited references

Currently, the entire bibliography is listed on the Refs page. The expected behaviour (as compared to most reference management software) would be to show only what was actually cited.

The behaviour could be configurable, e.g. with render-bib=[all,cited], with the latter as default.

[Rendering] Reference list - allow for selecting citation key

The current rendering of the references does not allow C&P of the citation key due to popup on hover.
Personally, I find the popup behaviour with motion in the following references a bit distracting.

Maybe it could be a solution to not show the citation key, but to provide a small link that copies it to the clipboard? Or to include the key in the details tags so it opens only on click?

Collaboration on this project

Hi @francisco-perez-sorrosal,

while thinking about a bibtex reference preprocessor for mdBook as a next hobby project, I stumbled upon your brand new repository. Instead of starting a competing project, I would like to ask whether you welcome contributions?

A few ideas for features/possible contributions:

  • Render only the cited items in the bibliography. I.e. when using your all-in-one bib file with a four-digit number of entries, only show what was actually used in the text. I would probably start with a PR on that.
  • An option for per-chapter bibliographies, e.g. for edited books with multiple authors/essays
  • Bibliography and in-line citation styles (syntax like/close to/subset of LaTeX EDIT: or through a custom .hbs file)
    • Incl. sorting of the bibliography, e.g. by first author or by citation order

I have only a few months of (however, fairly intensive) Rust experience. You may want to assess by a look into my Rust repositories.

Thanks for starting this very useful project!
Regards!

Release v0.0.5

Not sure if this was intentional, but the latest release has tag master. So this will not be published to crates.io.

Can we have a release v0.0.5 (incl. the resp. entry in Cargo.toml)? Or meybe even go for v0.1.0?

Release v0.3.0 binaries

Can we release binaries for the 0.3.0 version, so they can be downloaded by CI scripts to save the effort of building them using Cargo?

We could change the trigger in release.yaml to release creation:

on:
  release:
    types: [ created ]

Error with overwriting file used to render inline citations.

I want to adjust reference style for my mdbook, But I'm having a little trouble with author names. I tried the default approach by downloading references.hbs, adding it to my src folder and then adding hb-tpl = "references.hbs" to the TOML file as per the manual's instructions. Compilation is fine, but the resulting bibliography is missing the list of authors.

In the HTML I get:

<summary class=citation>
<a id="Knuth1974">[Knuth1974]</a> -  - <a href="http://portal.acm.org/citation.cfm?doid&#x3D;361604.361612" target="_blank"><cite>Computer programming as an art</cite></a>. - 1974. -
<button onclick="copyToClipboard('\{\{ #cite Knuth1974 \}\}')">Copy citation_key</button>
</summary>

instead of the expected (and default behavior if no hb-tpl is set in the TOML):

<summary class=citation>
<a id="Knuth1974">[Knuth1974]</a> - Knuth, Donald E. - <a href="http://portal.acm.org/citation.cfm?doid&#x3D;361604.361612" target="_blank"><cite>Computer programming as an art</cite></a>. - 1974. -
<button onclick="copyToClipboard('\{\{ #cite Knuth1974 \}\}')">Copy citation_key</button>
</summary>

encountered fatal runtime error: stack overflow when trying to build mdbook

after installation of mdbook-bib, I have encountered fatal runtime error: stack overflow when trying to build mdbook.

bib file is an example as show below
@book{DUMMY:1,
AUTHOR = "John Doe",
TITLE = "The Book without Title",
PUBLISHER = "Dummy Publisher",
YEAR = "2100",
}

in the markdown.md file, I just include the @@dummy:1 string but a fatal error is shown, please kindly help.

➜ docs git:(main) ✗ cargo install mdbook-bib

Updating crates.io index
 Ignored package `mdbook-bib v0.0.4` is already installed, use --force to override

➜ docs git:(main) ✗ mdbook build
2022-07-21 19:19:16 [INFO] (mdbook::book): Book building has started
Warning: The bib plugin was built against version 0.4.20 of mdbook, but we're being called from version 0.4.18
2022-07-21 19:19:16 [INFO] (mdbook_bib): Processor Name: bib
2022-07-21 19:19:16 [INFO] (mdbook_bib::config): Using default HB template...
2022-07-21 19:19:16 [INFO] (mdbook_bib::config): Using default CSS template...
2022-07-21 19:19:16 [INFO] (mdbook_bib::config): Using default JS template...
2022-07-21 19:19:16 [INFO] (mdbook_bib): Bibliography file: biblio.bib
2022-07-21 19:19:16 [INFO] (mdbook_bib): Bibliography path: /Users/mac/Repo/waxctech.github.io/docs/src/biblio.bib
2022-07-21 19:19:16 [INFO] (mdbook_bib): Loading bibliography from "/Users/mac/Repo/waxctech.github.io/docs/src/biblio.bib"...
2022-07-21 19:19:16 [INFO] (mdbook_bib): Building bibliography...

thread 'main' has overflowed its stack
fatal runtime error: stack overflow
2022-07-21 19:19:16 [ERROR] (mdbook::utils): Error: The "bib" preprocessor exited unsuccessfully with signal: 6 status
➜ docs git:(main) ✗

Does not work for nested paths

Problem

When you cite a publication in a file that is not in the root src directory but rather in a subdirectory, the generated link to the Bibliography page contains the path to the subdirectory and thus does not work.

Possible Solutions

  • Get current path and generate the relative path to the Bibliography page correctly (probably the best solution)
  • Add a Bibliography page to each subdirectory with citations (probably not desired)

If you can't work on this issue, but are willing to accept a PR, I will do my best to provide one when I find the time.

Thanks for the plugin!

Deploy to releases

Provide downloadable binaries for Linux, Windows and MacOS, for those not using cargo.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.