Skip to content

Commit 2850c36

Browse files
committed
Differentiate between dependency types
Some dependencies also inject supporting HTML tags and can carry attributes and other metadata. Simple dependencies are just files that are copied. fix
1 parent ad8ed05 commit 2850c36

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/command/render/pandoc-dependencies-html.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ function processHtmlDependencies(
217217

218218
const copyFile = (
219219
file: DependencyFile,
220+
attribs?: Record<string, string>,
221+
afterBody?: boolean,
220222
inject?: (
221223
href: string,
222224
attribs?: Record<string, string>,
@@ -230,7 +232,7 @@ function processHtmlDependencies(
230232
);
231233
if (inject) {
232234
const href = join(directoryInfo.relative, file.name);
233-
inject(href, file.attribs, file.afterBody);
235+
inject(href, attribs, afterBody);
234236
}
235237
};
236238

@@ -239,6 +241,8 @@ function processHtmlDependencies(
239241
dependency.scripts.forEach((script) =>
240242
copyFile(
241243
script,
244+
script.attribs,
245+
script.afterBody,
242246
injector.injectScript,
243247
)
244248
);
@@ -249,6 +253,8 @@ function processHtmlDependencies(
249253
dependency.stylesheets.forEach((stylesheet) => {
250254
copyFile(
251255
stylesheet,
256+
stylesheet.attribs,
257+
stylesheet.afterBody,
252258
injector.injectStyle,
253259
);
254260
});

src/config/types.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,18 @@ export interface FormatDependency {
204204
external?: boolean;
205205
meta?: Record<string, string>;
206206
links?: { rel: string; href: string; type?: string }[];
207-
scripts?: DependencyFile[];
208-
stylesheets?: DependencyFile[];
207+
scripts?: DependencyHtmlFile[];
208+
stylesheets?: DependencyHtmlFile[];
209209
head?: string;
210210
resources?: DependencyFile[];
211211
}
212212

213213
export interface DependencyFile {
214214
name: string;
215215
path: string;
216+
}
217+
218+
export interface DependencyHtmlFile extends DependencyFile {
216219
attribs?: Record<string, string>;
217220
afterBody?: boolean;
218221
}

src/format/html/format-html.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ import {
3131

3232
import {
3333
DependencyFile,
34+
DependencyHtmlFile,
3435
Format,
3536
FormatDependency,
3637
FormatExtras,
@@ -187,8 +188,8 @@ export async function htmlFormatExtras(
187188
}
188189

189190
// lists of scripts and ejs data for the orchestration script
190-
const scripts: DependencyFile[] = [];
191-
const stylesheets: DependencyFile[] = [];
191+
const scripts: DependencyHtmlFile[] = [];
192+
const stylesheets: DependencyHtmlFile[] = [];
192193
const sassBundles: SassBundle[] = [];
193194
const dependencies: FormatDependency[] = [];
194195

0 commit comments

Comments
 (0)