Skip to content

Commit f955b96

Browse files
committed
provide relative path to bibliography for pandoc
1 parent 9582f0d commit f955b96

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*
66
*/
77

8-
import { dirname, join, relative } from "path/mod.ts";
8+
import { dirname, isAbsolute, join, relative } from "path/mod.ts";
99
import { existsSync } from "fs/mod.ts";
1010

1111
import * as ld from "../../../core/lodash.ts";
@@ -150,7 +150,6 @@ export async function bookBibliographyPostRender(
150150
csl,
151151
citeIds,
152152
);
153-
154153
const newRefsDiv = refsOutputFile.doc.createElement("div");
155154
newRefsDiv.innerHTML = biblioHtml;
156155
const refsDiv = refsOutputFile.doc.getElementById("refs") as Element;
@@ -169,13 +168,21 @@ export async function bookBibliographyPostRender(
169168

170169
async function generateBibliographyHTML(
171170
context: ProjectContext,
172-
bibliography: unknown,
171+
bibliography: string[],
173172
csl: unknown,
174173
citeIds: string[],
175174
) {
175+
const biblioPaths = bibliography.map((biblio) => {
176+
if (isAbsolute(biblio)) {
177+
return relative(context.dir, biblio);
178+
} else {
179+
return biblio;
180+
}
181+
});
182+
176183
// make the aggregated bibliography
177184
const yaml: Metadata = {
178-
bibliography,
185+
bibliography: biblioPaths,
179186
nocite: ld.uniq(citeIds).map((id) => "@" + id).join(", "),
180187
};
181188
if (csl) {

0 commit comments

Comments
 (0)