Published
Edited
Sep 24, 2021
Importers
3 stars
Insert cell
Insert cell
Insert cell
viewof bibliography = bib({
Tegally2021: `Tegally, H., Wilkinson, E., Giovanetti, M. *et al*. Detection of a SARS-CoV-2 variant of concern in South Africa. *Nature* **592**, 438–443 (2021). https://doi.org/10.1038/s41586-021-03402-9`,
Chen2020: `F. Chen, L. Piccinini, P. Poncelet, and A. Sallaberry. Node Overlap Removal Algorithms: An Extended Comparative Study. *In Journal of Graph Algorithms and Applications*, Vol. 24, no. 4, pp. 683-706, 2020. Regular paper. http://doi.org/10.7155/jgaa.00532`,
somethingelseentirely2021: `somethingelseentirely. Papers. *Observable*. Website. https://observablehq.com/@somethingelseentirely/papers`
})
Insert cell
Insert cell
cite = viewof bibliography
Insert cell
Insert cell
bibliography
Insert cell
Insert cell
Insert cell
Insert cell
viewof bib = frepr(function (entries, options = {}) {
const {
numbered = true,
citation = defaultCitation,
entry = defaultEntry
} = options;

return new AdvancedSetter(new Map(), {
set(state, ...keys) {
return citation(
keys.map((key) => {
const ref = entries[key];
if (ref === undefined)
throw new Error(`${key} was not found in given bibliography`);

// const [id, render] = state.get(key); return citation(id, render);
if (state.has(key)) return [...state.get(key)];

const id = numbered ? state.size : key,
pair = [id, entry(ref, id)];
state.set(key, pair);

return pair;
})
);
},
get(state) {
return html`${Array.from(state.values(), ([, rendered]) => rendered)}`;
}
});
}, bibdoc)
Insert cell
Insert cell
Insert cell
defaultCitation = (citations) =>
html`[${addCommas(citations.map(([id, to]) => link(id, to)))}]`
Insert cell
defaultEntry = (value, id) => html`<div id="ref-${id}">${md`[${id}] ${value}`}`
Insert cell
addCommas = (list, separator = ", ") => {
const newList = [];
list.forEach((v, i) => {
if (i !== 0) newList.push(separator);
newList.push(v);
});
return newList;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more