Skip to content

Commit

Permalink
refa: quotes from yamlfm
Browse files Browse the repository at this point in the history
  • Loading branch information
Myllaume committed Oct 4, 2024
1 parent 7051c7c commit 6304265
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
17 changes: 16 additions & 1 deletion core/models/bibliography.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,28 @@ class Bibliography {

/**
* @param {string[]} quotesId
* @returns {BibliographicRecord[]}
*/

static getBibliographicRecordsFromList(quotesId = []) {
return quotesId.map((quoteId, index) => {
return {
quotesExtract: {
citationItems: [
{
prefix: '',
suffix: '',
id: quoteId,
label: 'page',
locator: '',
'suppress-author': false,
},
],
properties: { noteIndex: index + 1 },
},
text: '',
contexts: [],
id: quoteId,
ids: new Set([quoteId]),
};
});
}
Expand Down
9 changes: 6 additions & 3 deletions core/models/cosmoscope.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,14 +313,17 @@ class Cosmoscope extends Graph {
bibliography = new Bibliography(bib, cslStyle, xmlLocal);

for (const file of files) {
const bibliographicRecords = [
const quotesWithContexts = [
...quoteIdsWithContexts(file.content),
...Bibliography.getBibliographicRecordsFromList(file.metas.references),
...file.metas.references.map((quoteId) => ({
contexts: [],
id: quoteId,
})),
];

const fileId = file.metas['id'] || file.metas['title'].toLowerCase();

bibliographicRecords.forEach(({ id, contexts }) => {
quotesWithContexts.forEach(({ id, contexts }) => {
if (!bibliography.library[id]) return;

if (referenceRecords.has(id)) {
Expand Down

0 comments on commit 6304265

Please sign in to comment.