Skip to content

Commit f69096f

Browse files
committed
Allow book extensions to contribute filter params
1 parent 2693f55 commit f69096f

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/project/types/book/book-shared.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77

88
import { RenderedFile } from "../../../command/render/types.ts";
9+
import { PandocOptions, RenderedFile } from "../../../command/render/types.ts";
910
import { kTitle } from "../../../config/constants.ts";
1011
import { Format } from "../../../config/types.ts";
1112
import { parsePandocTitle } from "../../../core/pandoc/pandoc-partition.ts";
@@ -41,6 +42,8 @@ export interface BookExtension {
4142
// bool extensions are single file by default but can elect to be multi file
4243
multiFile?: boolean;
4344

45+
filterParams?: (options: PandocOptions) => Record<string, unknown>;
46+
4447
formatOutputDirectory?: (format: Format) => string;
4548

4649
// book extensions can modify the format before render

src/project/types/book/book.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,18 @@ export const bookProjectType: ProjectType = {
136136
},
137137

138138
filterParams: (options: PandocOptions) => {
139+
const bookExt = options.format.extensions?.book as BookExtension;
140+
const filterParams = bookExt.filterParams
141+
? bookExt.filterParams(options)
142+
: {};
139143
if (isMultiFileBookFormat(options.format)) {
140144
return {
145+
...filterParams,
141146
[kCrossrefResolveRefs]: false,
142147
};
143148
} else {
144149
return {
150+
...filterParams,
145151
[kSingleFileBook]: true,
146152
};
147153
}

0 commit comments

Comments
 (0)