rehype-citation

Rehype plugin to add citation and bibliography from bibtex files

https://github.com/timlrx/rehype-citation

Science Score: 77.0%

This score indicates how likely this project is to be science-related based on various indicators:

  • CITATION.cff file
    Found CITATION.cff file
  • codemeta.json file
    Found codemeta.json file
  • .zenodo.json file
    Found .zenodo.json file
  • DOI references
    Found 1 DOI reference(s) in README
  • Academic publication links
    Links to: zenodo.org
  • Committers with academic emails
    1 of 7 committers (14.3%) from academic institutions
  • Institutional organization owner
  • JOSS paper metadata
  • Scientific vocabulary similarity
    Low similarity (10.3%) to scientific vocabulary

Keywords

bibliography bibtex citations markdown mdx rehype rehype-plugin
Last synced: 6 months ago · JSON representation ·

Repository

Rehype plugin to add citation and bibliography from bibtex files

Basic Info
Statistics
  • Stars: 59
  • Watchers: 3
  • Forks: 12
  • Open Issues: 3
  • Releases: 24
Topics
bibliography bibtex citations markdown mdx rehype rehype-plugin
Created over 4 years ago · Last pushed 11 months ago
Metadata Files
Readme Funding License Citation

README.md

rehype citation

Rehype-Citation

GitHub Repo stars GitHub forks Twitter URL Sponsor DOI

rehype plugin to nicely format citations in markdown documents and insert bibliography in html format. It is meant to be used as a server side plugin and neatly integrates citeproc-js and citation-js within the remark-rehype ecosystem. Parsing of citations and all the wonderful regexes are adapted from Zettlr.

It supports both normal citations (such as [@foo]) and in-text citation (such as @foo), as well as author-date, numerical, and note styles.

Note styles is only compatible with Github Formatted Markdown (GFM). It is recommended to run remark-gfm before rehype-citation to ensure all footnote elements are correctly formatted.

API and options follows very closely to Rmarkdown and Pandoc

Examples

Installation

This package is ESM only: Node 12+ is needed to use it and it must be imported instead of required.

js npm install rehype-citation

Usage

If you are using the plugin in a node environment, import from rehype-citation/node. For browser environments, import from rehype-citation/browser.

The following files are exported:

generator, generator function. Can be used to generate a rehype citation plugin. Takes in a citation-js Cite class. cite, a citation-js Cite instance. Add your own CSL / locales before passing in to the plugin generator . rehype-citation, re-exports the above 2 packages with a pre-configured rehype-citation plugin ready to use. Importing from rehype-citation directs to this file.

Use this package as a rehype plugin.

Some examples of how you might do that:

```js import rehype from 'rehype' import rehypeCitation from 'rehype-citation'

rehype().use(rehypeCitation).process(/* some html */) ```

Sample markdown to HTML output

Input:

md My markdown text [@Nash1950]

HTML Output:

html <div>My markdown text (Nash, 1950)</div> <div id="refs" class="references csl-bib-body"> <div class="csl-entry"> Nash, J. (1950). Equilibrium points in n-person games. <i>Proceedings of the National Academy of Sciences</i>, <i>36</i>(1), 48–49. </div> </div>

Generating your own remark citation plugins

The default plugin comes configured with the en-US locale and the following CSL styles: apa, vancouver, harvard1, chicago and mla.

Use the generator function to customize your own remark-citation plugin and add your own CSL styles or locales.

```js import Cite from 'rehype-citation/cite' import rehypeCitationGenerator from 'rehype-citation/generator' import myStyle from '../style' import myLocale from '../locale'

const config = Cite.plugins.config.get('@csl') config.templates.add('mystyle', myStyle) config.locales.add('myLocale', myLocale)

const rehypeCitation = rehypeCitationGenerator(Cite) ```

API

rehype().use(rehypeCitation, [options])

If no bibliography file is passed, the plugin will be skipped.

options

options.bibliography

Type: string|string[].

By default, if no bibliography file is passed, the plugin will be skipped.

Name or path to Bibtex, CSL-JSON or CFF file. If multiple files are provided, they will be merged.

options.path

Type: string. Default: process.cwd().

Required, path to file. Will be joined with options.bibliography and options.csl, if provided.

options.csl

Type: 'apa'|'vancouver'|'harvard1'|'chicago'|'mla'|string. Default: apa.

For the main rehypeCitation plugin, one of 'apa', 'vancouver', 'harvard1', 'chicago', 'mla'. A local file path or URL to a valid CSL file is also accepted. Can also be specified as a frontmatter option in the markdown file to override the default.

options.lang

Type: string. Default: en-US.

Locale to use in formatting citations. Defaults to en-US. A local file path or URL to a valid locale file is also accepted.

options.suppressBibliography

Type: boolean. Default: false.

Suppress bibliography? By default, biliography is inserted after the entire markdown file. If the file contains [^ref], the biliography will be inserted there instead.

options.noCite

Type: string[].

Citation IDs (@item1) to include in the bibliography even if they are not cited in the document. Can also be specified as a frontmatter option in the markdown file.

options.inlineClass

Type: string[].

Array of classes for inline citations.

options.inlineBibClass

Type: string[].

Array of classes for inline bibliography. Leave empty to disable inline bibliography.

options.linkCitations

Type: boolean. Default: false.

If true, citations will be hyperlinked to the corresponding bibliography entries (for author-date and numeric styles only).

options.showTooltips

Type: boolean. Default: false.

If true, citations will display tooltips containing the full bibliography entry when hovered. For multiple citations, each reference will have its own tooltip. When used with linkCitations: true, tooltips are added to each individual link.

options.tooltipAttribute

Type: string. Default: title.

The HTML attribute to use for tooltips. By default, the standard HTML title attribute is used, but you can specify an alternative attribute (e.g., data-tooltip) for custom tooltip implementations or to work with specific tooltip libraries.

Owner

  • Name: Timothy
  • Login: timlrx
  • Kind: user
  • Location: Singapore

Citation (CITATION.cff)

cff-version: 1.2.0
title: Rehype Citation
message: >-
  If you use this software, please cite it using the
  metadata from this file.
type: software
authors:
  - given-names: Timothy
    family-names: Lin
identifiers:
  - type: doi
    value: 10.5281/zenodo.10004327
abstract: >-
  Rehype plugin to add citations and bibliography from
  multiple file formats
license: MIT
date-released: 2023-10-15
doi: 10.5281/zenodo.10004327

GitHub Events

Total
  • Create event: 6
  • Release event: 2
  • Issues event: 7
  • Watch event: 21
  • Issue comment event: 25
  • Push event: 10
  • Pull request review event: 1
  • Pull request review comment event: 1
  • Pull request event: 10
  • Fork event: 5
Last Year
  • Create event: 6
  • Release event: 2
  • Issues event: 7
  • Watch event: 21
  • Issue comment event: 25
  • Push event: 10
  • Pull request review event: 1
  • Pull request review comment event: 1
  • Pull request event: 10
  • Fork event: 5

Committers

Last synced: 9 months ago

All Time
  • Total Commits: 142
  • Total Committers: 7
  • Avg Commits per committer: 20.286
  • Development Distribution Score (DDS): 0.077
Past Year
  • Commits: 27
  • Committers: 5
  • Avg Commits per committer: 5.4
  • Development Distribution Score (DDS): 0.296
Top Committers
Name Email Commits
Timothy Lin t****6@h****m 131
halafy-ds 6****s 5
Ugo Finnendahl f****l@t****e 2
Pierre Lairez p****e@l****r 1
Johannes Kopton j****s@k****g 1
Chaichontat Sriworarat 3****t 1
Aaron Pham c****t@a****z 1
Committer Domains (Top 20 + Academic)

Issues and Pull Requests

Last synced: 6 months ago

All Time
  • Total issues: 25
  • Total pull requests: 31
  • Average time to close issues: 24 days
  • Average time to close pull requests: 2 days
  • Total issue authors: 20
  • Total pull request authors: 7
  • Average comments per issue: 1.8
  • Average comments per pull request: 1.39
  • Merged pull requests: 25
  • Bot issues: 0
  • Bot pull requests: 0
Past Year
  • Issues: 7
  • Pull requests: 9
  • Average time to close issues: 14 days
  • Average time to close pull requests: 4 days
  • Issue authors: 6
  • Pull request authors: 5
  • Average comments per issue: 1.43
  • Average comments per pull request: 2.33
  • Merged pull requests: 5
  • Bot issues: 0
  • Bot pull requests: 0
Top Authors
Issue Authors
  • timlrx (3)
  • ugogon (2)
  • chaichontat (2)
  • igor-koop (2)
  • activatedgeek (1)
  • franco-ruggeri (1)
  • 0xCaso (1)
  • risangbaskoro (1)
  • MarkusKonk (1)
  • harleylara (1)
  • adnjoo (1)
  • mvsoom (1)
  • ahmadassaf (1)
  • tcosmo (1)
  • songololo (1)
Pull Request Authors
  • timlrx (23)
  • halafy-ds (9)
  • aarnphm (4)
  • ugogon (2)
  • johanneskopton (2)
  • lairez (2)
  • chaichontat (1)
Top Labels
Issue Labels
bug (2) enhancement (2)
Pull Request Labels
enhancement (2)

Packages

  • Total packages: 2
  • Total downloads:
    • npm 149,512 last-month
  • Total docker downloads: 14
  • Total dependent packages: 7
    (may contain duplicates)
  • Total dependent repositories: 450
    (may contain duplicates)
  • Total versions: 46
  • Total maintainers: 2
npmjs.org: rehype-citation

rehype plugin to add citation and bibliography from bibtex files

  • Versions: 44
  • Dependent Packages: 7
  • Dependent Repositories: 450
  • Downloads: 149,507 Last month
  • Docker Downloads: 14
Rankings
Dependent repos count: 0.8%
Downloads: 1.6%
Average: 5.0%
Dependent packages count: 5.8%
Stargazers count: 7.5%
Forks count: 9.1%
Maintainers (1)
Last synced: 7 months ago
npmjs.org: @prabhavag/rehype-citation

rehype plugin to add citation and bibliography from bibtex files

  • Versions: 2
  • Dependent Packages: 0
  • Dependent Repositories: 0
  • Downloads: 5 Last month
Rankings
Stargazers count: 5.4%
Forks count: 5.7%
Average: 18.4%
Dependent repos count: 25.6%
Dependent packages count: 37.0%
Maintainers (1)
Last synced: 7 months ago

Dependencies

package-lock.json npm
  • 762 dependencies
package.json npm
  • @esbuild-plugins/node-globals-polyfill ^0.1.1 development
  • @esbuild-plugins/node-modules-polyfill ^0.1.4 development
  • @playwright/test ^1.18.1 development
  • @types/node ^16.11.1 development
  • @vitejs/plugin-react ^1.1.4 development
  • dedent ^0.7.0 development
  • eslint ^7.32.0 development
  • eslint-config-prettier ^8.3.0 development
  • eslint-plugin-node ^11.1.0 development
  • glob ^7.2.0 development
  • husky ^4.0.0 development
  • lint-staged ^11.1.2 development
  • microbundle ^0.14.1 development
  • prettier ^2.3.2 development
  • react ^17.0.2 development
  • react-dom ^17.0.2 development
  • rehype ^12.0.0 development
  • rollup-plugin-polyfill-node ^0.8.0 development
  • rollup-plugin-visualizer ^5.5.4 development
  • typescript ^4.3.5 development
  • uvu ^0.5.1 development
  • vite ^2.7.13 development
  • @citation-js/core ^0.5.4
  • @citation-js/date ^0.5.1
  • @citation-js/name ^0.4.2
  • @citation-js/plugin-bibjson ^0.5.4
  • @citation-js/plugin-bibtex ^0.5.5
  • @citation-js/plugin-csl ^0.5.5
  • citeproc ^2.4.62
  • cross-fetch ^3.1.5
  • hast-util-from-dom ^4.1.0
  • hast-util-from-parse5 ^7.1.0
  • parse5 ^6.0.1
  • rehype-citation ^0.2.5-rc.0
  • unified ^10.1.0
  • unist-util-visit ^4.0.0
.github/workflows/e2e.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite
.github/workflows/unit.yml actions
  • actions/checkout v3 composite
  • actions/setup-node v3 composite