Skip to content

Commit 33736f6

Browse files
committed
If keeptex is specified, forward that along to the individual files when cleaning up
1 parent 887b83d commit 33736f6

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

src/format/pdf/format-pdf.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ import { Format, FormatExtras, PandocFlags } from "../../config/types.ts";
4242
import { createFormat } from "../formats-shared.ts";
4343

4444
import { RenderedFile, RenderServices } from "../../command/render/types.ts";
45-
import { ProjectContext } from "../../project/types.ts";
45+
import { ProjectConfig, ProjectContext } from "../../project/types.ts";
4646
import { BookExtension } from "../../project/types/book/book-shared.ts";
4747

4848
import { readLines } from "io/buffer.ts";
@@ -88,6 +88,16 @@ export function latexFormat(displayName: string): Format {
8888
{
8989
extensions: {
9090
book: {
91+
onSingleFilePreRender: (
92+
format: Format,
93+
_config?: ProjectConfig,
94+
) => {
95+
// If we're targeting LaTeX output, be sure to keep
96+
// the supporting files around (since we're not building
97+
// them into a PDF)
98+
format.render[kKeepTex] = true;
99+
return format;
100+
},
91101
formatOutputDirectory: () => {
92102
return "book-latex";
93103
},

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
kDoi,
2525
kFormatLinks,
2626
kHideDescription,
27+
kKeepTex,
2728
kNumberSections,
2829
kOutputExt,
2930
kOutputFile,
@@ -347,6 +348,10 @@ async function renderSingleFileBook(
347348

348349
// cleanup step for each executed file
349350
files.forEach((file) => {
351+
// Forward render cleanup options from parent format
352+
file.recipe.format.render[kKeepTex] =
353+
executedFile.recipe.format.render[kKeepTex];
354+
350355
cleanupExecutedFile(
351356
file,
352357
join(project.dir, renderedFile.file),

0 commit comments

Comments
 (0)