Public
Edited
Feb 8, 2024
Insert cell
Insert cell
Insert cell
nodes = {
const doc = new DOMParser().parseFromString(hca_pubs, "text/html");
return Array.from(doc.querySelectorAll(".pub-entry"));
}
Insert cell
{
const text = bibtex;
const type = "text/plain";
const name = "observableHCA.bib"
const a = document.createElement("a");
const file = new Blob([text], {type: type});
const url = URL.createObjectURL(file);
a.href = url;
a.download = name;
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
Insert cell
peerReviewedNodes = nodes.filter(n => {
return n.getAttribute("data-journal_type") === "Peer reviewed";
//return JSON.parse(n.getAttribute("data-topics")).includes("Open Access Data")
});
Insert cell
peerReviewedSince2019Nodes = peerReviewedNodes.filter(n => {
const year = n.querySelector("span.year").innerHTML;
return parseInt(year) >= 2019;
});
Insert cell
bibtex = peerReviewedSince2019Nodes.map(n => {
const names = Array.from(n.querySelectorAll("span.author"))
.map(n => n.innerHTML)
.filter(t => t.trim().length > 0)
.at(0).split(" ");
const lastName = (names[0].length === 1 ? names.at(-1) : names.at(0)).replace(/[^a-z0-9]/gi, '');
const title = n.querySelector("h4.article").innerHTML;
const firstWord = title.split(" ").at(0).replace(/[^a-z0-9]/gi, '');
const doi = Array.from(n.querySelectorAll("a")).map(l => l.innerHTML).find(t => t.startsWith("DOI: "))?.substring(5);
const year = n.querySelector("span.year").innerHTML;
const author = Array.from(n.querySelectorAll("span.author")).map(s => s.innerHTML).join(" and ");
const journal = n.querySelector("p.publication > span.title").innerHTML
return `@article{${lastName.toLowerCase()}${year}${firstWord.toLowerCase()},
title = {${title}},
doi = {${doi}},
year = {${year}},
journal = {${journal}},
author = {${author}}
}`
}).join("\n")
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more