Public
Edited
Mar 19, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function customAnnots1Function(annotations){
return annotations
// Only use text highlights, not image highlights
.filter(annot => annot.type == "highlight")
.map(annot => {
// Render the highlighted text as a quote block, with quote marks around it, and the page number added at the end
const highlightBlock = `[[>]] "${annot.text}" (p. ${annot.page_label})`;
// If there is no attached comment, just return the highlight block
if(!annot.comment){
return highlightBlock;
} else {
// Otherwise, return the comment with the highlight indented underneath
return {
string: annot.comment,
children: [highlightBlock]
};
}
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function customAnnots2Function(annotations){
const annots_grouped_by_date = annotations
// Only use text highlights
.filter(annot => annot.data.annotationType == "highlight")
// Group annotations by date added
.reduce((list, annot) => {
const ymd = new Date(annot.data.dateAdded).toLocaleDateString("en-CA");
if(list[ymd]){
list[ymd].push(annot);
} else {
list[ymd] = [annot];
}
return list;
}, {});
return Object.keys(annots_grouped_by_date)
// Sort groups by date (oldest to newest)
.sort((a,b) => new Date(a.split("-")) < new Date(b.split("-")) ? -1 : 1)
.map(date => {
const annots = annots_grouped_by_date[date];
return {
// Nest annotations under a block with the [[DNP]] for that date
string: zoteroRoam.getItemDateAdded(annots[0], { brackets: true }),
children: annots
// For each annotation, return the highlighted text then the related comment underneath (if any, tag it with #me)
.map(annot => ({
string: annot.data.annotationText,
children: annot.data.annotationComment ? [annot.data.annotationComment + " #me"] : []
}))
};
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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