{"id":15130865,"url":"https://github.com/timlrx/rehype-citation","last_synced_at":"2026-02-08T14:09:31.936Z","repository":{"id":42465262,"uuid":"419657013","full_name":"timlrx/rehype-citation","owner":"timlrx","description":"Rehype plugin to add citation and bibliography from bibtex files","archived":false,"fork":false,"pushed_at":"2024-10-25T12:45:11.000Z","size":1360,"stargazers_count":39,"open_issues_count":1,"forks_count":7,"subscribers_count":5,"default_branch":"main","last_synced_at":"2024-10-29T20:50:51.585Z","etag":null,"topics":["bibliography","bibtex","citations","markdown","mdx","rehype","rehype-plugin"],"latest_commit_sha":null,"homepage":"https://rehype-citation.netlify.app","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/timlrx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"timlrx"}},"created_at":"2021-10-21T09:17:43.000Z","updated_at":"2024-10-27T05:58:38.000Z","dependencies_parsed_at":"2024-06-18T20:07:44.161Z","dependency_job_id":"bb657977-3375-464e-8971-25d6b2ea9148","html_url":"https://github.com/timlrx/rehype-citation","commit_stats":{"total_commits":129,"total_committers":6,"mean_commits":21.5,"dds":0.4651162790697675,"last_synced_commit":"bcd598ee00bf7ef89bbf8f9138057e17c28b9719"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timlrx%2Frehype-citation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timlrx%2Frehype-citation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timlrx%2Frehype-citation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timlrx%2Frehype-citation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timlrx","download_url":"https://codeload.github.com/timlrx/rehype-citation/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305932,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bibliography","bibtex","citations","markdown","mdx","rehype","rehype-plugin"],"created_at":"2024-09-26T03:07:32.156Z","updated_at":"2026-02-08T14:09:31.885Z","avatar_url":"https://github.com/timlrx.png","language":"JavaScript","funding_links":["https://github.com/sponsors/timlrx","https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026link=https://github.com/sponsors/timlrx"],"categories":[],"sub_categories":[],"readme":"![rehype citation](./rehype-citation.png)\n\n# Rehype-Citation\n\n[![GitHub Repo stars](https://img.shields.io/github/stars/timlrx/rehype-citation?style=social)](https://GitHub.com/timlrx/rehype-citation/stargazers/)\n[![GitHub forks](https://img.shields.io/github/forks/timlrx/rehype-citation?style=social)](https://GitHub.com/timlrx/rehype-citation/network/)\n[![Twitter URL](https://img.shields.io/twitter/url?style=social\u0026url=https%3A%2F%2Ftwitter.com%2Ftimlrxx)](https://twitter.com/timlrxx)\n[![Sponsor](https://img.shields.io/static/v1?label=Sponsor\u0026message=%E2%9D%A4\u0026logo=GitHub\u0026link=https://github.com/sponsors/timlrx)](https://github.com/sponsors/timlrx)\n[![DOI](https://zenodo.org/badge/419657013.svg)](https://zenodo.org/doi/10.5281/zenodo.10004327)\n\n[rehype](https://github.com/wooorm/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](https://github.com/Juris-M/citeproc-js) and [citation-js](https://github.com/citation-js/citation-js) within the remark-rehype ecosystem. Parsing of citations and all the wonderful regexes are adapted from [Zettlr](https://github.com/Zettlr/Zettlr).\n\nIt supports both normal citations (such as [@foo]) and in-text citation (such as @foo), as well as author-date, numerical, and note styles.\n\nNote 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.\n\nAPI and options follows very closely to [Rmarkdown](https://bookdown.org/yihui/rmarkdown-cookbook/bibliography.html) and [Pandoc](https://pandoc.org/MANUAL.html#citations)\n\n## Examples\n\n- [Citations with Bibliography](https://rehype-citation.netlify.app)\n- [Suppress Bibliography](https://rehype-citation.netlify.app/suppress-bibliography)\n- [Custom CSL](https://rehype-citation.netlify.app/custom-csl)\n- [Footnote style](https://rehype-citation.netlify.app/footnote-style)\n- [Link Citations](https://rehype-citation.netlify.app/link-citations)\n- [Tooltips](https://rehype-citation.netlify.app/tooltips)\n\n## Installation\n\nThis package is [ESM only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c):\nNode 12+ is needed to use it and it must be `import`ed instead of `require`d.\n\n```js\nnpm install rehype-citation\n```\n\n## Usage\n\nIf you are using the plugin in a node environment, import from `rehype-citation/node`. For browser environments, import from `rehype-citation/browser`.\n\nThe following files are exported:\n\n`generator`, generator function. Can be used to generate a rehype citation plugin. Takes in a citation-js `Cite` class.\n`cite`, a citation-js `Cite` instance. Add your own CSL / locales before passing in to the plugin generator .\n`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.\n\nUse this package [as a rehype plugin](https://github.com/rehypejs/rehype/blob/master/doc/plugins.md#using-plugins).\n\nSome examples of how you might do that:\n\n```js\nimport rehype from 'rehype'\nimport rehypeCitation from 'rehype-citation'\n\nrehype().use(rehypeCitation).process(/* some html */)\n```\n\n## Sample markdown to HTML output\n\nInput:\n\n```md\nMy markdown text [@Nash1950]\n```\n\nHTML Output:\n\n```html\n\u003cdiv\u003eMy markdown text (Nash, 1950)\u003c/div\u003e\n\u003cdiv id=\"refs\" class=\"references csl-bib-body\"\u003e\n  \u003cdiv class=\"csl-entry\"\u003e\n    Nash, J. (1950). Equilibrium points in n-person games.\n    \u003ci\u003eProceedings of the National Academy of Sciences\u003c/i\u003e, \u003ci\u003e36\u003c/i\u003e(1), 48–49.\n  \u003c/div\u003e\n\u003c/div\u003e\n```\n\n## Generating your own remark citation plugins\n\nThe default plugin comes configured with the `en-US` locale and the following CSL styles: apa, vancouver, harvard1, chicago and mla.\n\nUse the generator function to customize your own remark-citation plugin and add your own [CSL styles](https://github.com/citation-style-language/styles) or [locales](https://github.com/citation-style-language/locales).\n\n```js\nimport Cite from 'rehype-citation/cite'\nimport rehypeCitationGenerator from 'rehype-citation/generator'\nimport myStyle from '../style'\nimport myLocale from '../locale'\n\nconst config = Cite.plugins.config.get('@csl')\nconfig.templates.add('mystyle', myStyle)\nconfig.locales.add('myLocale', myLocale)\n\nconst rehypeCitation = rehypeCitationGenerator(Cite)\n```\n\n## API\n\n`rehype().use(rehypeCitation, [options])`\n\nIf no `bibliography` file is passed, the plugin will be skipped.\n\n### options\n\n#### options.bibliography\n\nType: `string|string[]`.\n\nBy default, if no `bibliography` file is passed, the plugin will be skipped.\n\nName or path to Bibtex, CSL-JSON or CFF file. If multiple files are provided, they will be merged.\n\n#### options.path\n\nType: `string`.\nDefault: `process.cwd()`.\n\nRequired, path to file. Will be joined with `options.bibliography` and `options.csl`, if provided.\n\n#### options.csl\n\nType: `'apa'|'vancouver'|'harvard1'|'chicago'|'mla'|string`.\nDefault: `apa`.\n\nFor 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.\n\n#### options.lang\n\nType: `string`.\nDefault: `en-US`.\n\nLocale to use in formatting citations. Defaults to `en-US`. A local file path or URL to a valid locale file is also accepted.\n\n#### options.suppressBibliography\n\nType: `boolean`.\nDefault: `false`.\n\nSuppress bibliography? By default, biliography is inserted after the entire markdown file. If the file contains `[^ref]`, the biliography will be inserted there instead.\n\n#### options.noCite\n\nType: `string[]`.\n\nCitation 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.\n\n#### options.inlineClass\n\nType: `string[]`.\n\nArray of classes for inline citations.\n\n#### options.inlineBibClass\n\nType: `string[]`.\n\nArray of classes for inline bibliography. Leave empty to disable inline bibliography.\n\n#### options.linkCitations\n\nType: `boolean`.\nDefault: `false`.\n\nIf true, citations will be hyperlinked to the corresponding bibliography entries (for author-date and numeric styles only).\n\n#### options.showTooltips\n\nType: `boolean`.\nDefault: `false`.\n\nIf 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.\n\n#### options.tooltipAttribute\n\nType: `string`.\nDefault: `title`.\n\nThe 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimlrx%2Frehype-citation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimlrx%2Frehype-citation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimlrx%2Frehype-citation/lists"}