Skip to content

Commit e9db2b7

Browse files
committed
Write individual chapters if they’re mutated
Fixes #4791
1 parent 42fdd0d commit e9db2b7

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ export async function bookBibliographyPostRender(
139139
// still used by citations-hover)
140140
const citeIds: string[] = [];
141141
for (const file of outputFiles) {
142+
let changed = false;
143+
142144
// relative path to refs html
143145
const refsRelative = pathWithForwardSlashes(
144146
relative(dirname(file.file), refsHtml!),
@@ -153,13 +155,23 @@ export async function bookBibliographyPostRender(
153155
for (let l = 0; l < citeLinks.length; l++) {
154156
const link = citeLinks[l] as Element;
155157
link.setAttribute("href", refsRelative + link.getAttribute("href"));
158+
changed = true;
156159
}
157160
});
158161

159162
// hide the bibliography
160163
const refsDiv = doc.getElementById("refs");
161164
if (refsDiv) {
162165
refsDiv.setAttribute("style", "display: none");
166+
changed = true;
167+
}
168+
169+
if (changed) {
170+
await writeDomToHtmlFile(
171+
doc,
172+
file.file,
173+
file.doctype,
174+
);
163175
}
164176
}
165177

0 commit comments

Comments
 (0)