Skip to content

Commit

Permalink
Merge pull request #34 from timlrx/plugin/cff
Browse files Browse the repository at this point in the history
Add support for multiple bibliography files
  • Loading branch information
timlrx committed Oct 15, 2023
2 parents 1e4db8c + 015f085 commit e8b44bd
Show file tree
Hide file tree
Showing 23 changed files with 773 additions and 796 deletions.
File renamed without changes.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ If no `bibliography` file is passed, the plugin will be skipped.

#### options.bibliography

Type: `string`.
Type: `string|string[]`.

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

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

#### options.path

Expand Down
19 changes: 18 additions & 1 deletion demo/app/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
CustomCSLExample,
FootnotesExample,
LinkCitationsExample,
CFFExample,
} from './md-examples'

const bibliography =
Expand All @@ -18,12 +19,17 @@ const acmCSL =
const chicagofullnoteCSL =
'https://raw.githubusercontent.com/citation-style-language/styles/master/chicago-fullnote-bibliography.csl'

const cff = 'https://raw.githubusercontent.com/timlrx/rehype-citation/main/test/CITATION.cff'
const cff2 = 'https://raw.githubusercontent.com/tensorflow/tensorflow/master/CITATION.cff'
const cff3 = 'https://raw.githubusercontent.com/langchain-ai/langchain/master/CITATION.cff'

const examples = [
'Default',
'Suppress Bibliography',
'Custom CSL',
'Footnote Style',
'Link Citations',
'Citation File Format',
]
const pathList = examples.map((e) => e.toLocaleLowerCase().replace(' ', '-'))

Expand Down Expand Up @@ -56,7 +62,10 @@ function App() {
))}
</div>
{selected === examples[0] && (
<Example markdown={defaultExample} rehypeCitationOptions={{ bibliography }} />
<Example
markdown={defaultExample}
rehypeCitationOptions={{ bibliography: [bibliography, cff] }}
/>
)}
{selected === examples[1] && (
<Example
Expand Down Expand Up @@ -91,6 +100,14 @@ function App() {
}}
/>
)}
{selected === examples[5] && (
<Example
markdown={CFFExample}
rehypeCitationOptions={{
bibliography: [cff, cff2, cff3],
}}
/>
)}
</div>
</>
)
Expand Down
7 changes: 3 additions & 4 deletions demo/app/main.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import React from 'react'
import ReactDOM from 'react-dom'
import ReactDOM from 'react-dom/client'
import App from './App'

ReactDOM.render(
ReactDOM.createRoot(document.getElementById('root')).render(
<React.StrictMode>
<App />
</React.StrictMode>,
document.getElementById('root')
</React.StrictMode>
)
24 changes: 22 additions & 2 deletions demo/app/md-examples.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ documents and insert bibliography in html format.
- Supports standard citations [@Nash1950{pp. iv, vi-xi, (xv)-(xvii)}];
- in-text citations, @Nash1951 [p. 33] says blah;
- and multiple citations [see @Nash1950 pp 12-13; @Nash1951]
- multiple citations [see @Nash1950 pp 12-13; @Nash1951];
- multiple sources [@10.5281/zenodo.1234]
Customizable CSL and locale.
Customizable CSL and locale. Bibtex, BibJSON, and CFF files are supported.
\`options.biliography\` can either be a string or an array with multiple sources.
### Bibliography
`
Expand Down Expand Up @@ -74,3 +77,20 @@ Implementation might differ from Pandoc, but if you run into any problems please
### Bibliography
`

export const CFFExample = `## Welcome
Supports CFF files as bibliography sources -
easily cite sources by their CITATION.cff file.
- Citation from Github cff file e.g. @10.5281/zenodo.1234 with DOI as key;
- Tensorflow citation [@10.5281/zenodo.4724125];
- Langchain citation with URL as key [@github.com/langchain-ai/langchain]
If a DOI is included, it will be used as the citation key.
Otherwise the URL will be used.
To cite, use the DOI reference directly or use the URL without the protocol (https://).
### Bibliography
`
Loading

0 comments on commit e8b44bd

Please sign in to comment.