Skip to content

Commit a5ff58b

Browse files
committed
Pass notebooks as filter params
1 parent 76e18f8 commit a5ff58b

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/command/render/filters.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ export async function filterParamsJson(
136136
...layoutFilterParams(options.format),
137137
...languageFilterParams(options.format.language),
138138
...jatsFilterParams(options),
139+
...notebookContextFilterParams(options),
139140
...filterParams,
140141
[kResultsFile]: pandocMetadataPath(resultsFile),
141142
[kTimingFile]: pandocMetadataPath(timingFile),
@@ -466,6 +467,16 @@ function jatsFilterParams(options: PandocOptions) {
466467
}
467468
}
468469

470+
function notebookContextFilterParams(options: PandocOptions) {
471+
const nbContext = options.services.notebook;
472+
const notebooks = nbContext.all();
473+
if (notebooks.length > 0) {
474+
return {
475+
"notebook-context": notebooks,
476+
};
477+
}
478+
}
479+
469480
async function quartoFilterParams(
470481
options: PandocOptions,
471482
defaults?: FormatPandoc,

src/render/notebook/notebook-context.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ export function notebookContext(): NotebookContext {
155155
}
156156

157157
return {
158+
all: () => {
159+
return Object.values(notebooks);
160+
},
158161
get: (nbAbsPath: string, context?: ProjectContext) => {
159162
const notebook = notebooks[nbAbsPath];
160163
const reviveRenders: RenderType[] = [];

src/render/notebook/notebook-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ export interface NotebookTemplateMetadata extends NotebookMetadata {
6868
export interface NotebookContext {
6969
// Retrieves the notebook from the context.
7070
get: (nbPath: string, context?: ProjectContext) => Notebook | undefined;
71+
all: () => Notebook[];
7172
// Resolves the data on an executedFile into data that will
7273
// create a `renderType` output when rendered.
7374
resolve: (

0 commit comments

Comments
 (0)