Skip to content

Commit 07731e4

Browse files
committed
Improve include names and error message
1 parent e2bc4c7 commit 07731e4

File tree

7 files changed

+24
-15
lines changed

7 files changed

+24
-15
lines changed

src/core/dart-sass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function dartCompile(
2828
): Promise<string | undefined> {
2929
// Write the scss to a file
3030
// We were previously passing it via stdin, but that can be overflowed
31-
const inputFilePath = temp.createFile({ suffix: "scss" });
31+
const inputFilePath = temp.createFile({ suffix: ".scss" });
3232

3333
// Write the css itself to a file
3434
Deno.writeTextFileSync(inputFilePath, input);

src/core/sass.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ export async function compileWithCache(
340340
}
341341
return outputFilePath;
342342
} else {
343-
const outputFilePath = temp.createFile({ suffix: "css" });
343+
const outputFilePath = temp.createFile({ suffix: ".css" });
344344
// Skip the cache and just compile
345345
await dartCompile(
346346
input,

src/format/html/format-html.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ export async function htmlFormatExtras(
288288
afterBody: true,
289289
});
290290

291-
const zenscrollStyle = temp.createFile({ suffix: ".html" });
291+
const zenscrollStyle = temp.createFile({ suffix: "-zen.html" });
292292
Deno.writeTextFileSync(
293293
zenscrollStyle,
294294
"<style>html{ scroll-behavior: smooth; }</style>",
@@ -396,7 +396,7 @@ export async function htmlFormatExtras(
396396

397397
// hypothesis
398398
if (options.hypothesis) {
399-
const hypothesisHeader = temp.createFile({ suffix: ".html" });
399+
const hypothesisHeader = temp.createFile({ suffix: "-hypoth.html" });
400400
Deno.writeTextFileSync(
401401
hypothesisHeader,
402402
renderEjs(
@@ -438,7 +438,7 @@ export async function htmlFormatExtras(
438438
}
439439
utterances["issue-term"] = utterances["issue-term"] || "pathname";
440440
utterances["theme"] = utterances["theme"] || "github-light";
441-
const utterancesAfterBody = temp.createFile({ suffix: ".html" });
441+
const utterancesAfterBody = temp.createFile({ suffix: "-utter.html" });
442442
Deno.writeTextFileSync(
443443
utterancesAfterBody,
444444
renderEjs(
@@ -483,7 +483,7 @@ export async function htmlFormatExtras(
483483
}
484484
}
485485

486-
const giscusAfterBody = temp.createFile({ suffix: ".html" });
486+
const giscusAfterBody = temp.createFile({ suffix: "-giscus.html" });
487487
Deno.writeTextFileSync(
488488
giscusAfterBody,
489489
renderEjs(

src/project/types/website/listing/website-listing.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function listingPostProcess(
406406
const kMarginSidebarId = "quarto-margin-sidebar";
407407

408408
function scriptFileForScripts(scripts: string[], temp: TempContext) {
409-
const scriptFile = temp.createFile({ suffix: "html" });
409+
const scriptFile = temp.createFile({ suffix: "-listing.html" });
410410
const contents = `<script>\n${scripts.join("\n")}</script>`;
411411
Deno.writeTextFileSync(scriptFile, contents);
412412
return scriptFile;

src/project/types/website/website-analytics.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ cookieconsent.run({
366366
}
367367

368368
function scriptFile(script: string, temp: TempContext) {
369-
const gaScriptFile = temp.createFile({ suffix: ".js" });
369+
const gaScriptFile = temp.createFile({ suffix: "-lytics.js" });
370370
Deno.writeTextFileSync(gaScriptFile, script);
371371
return gaScriptFile;
372372
}

src/project/types/website/website-search.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@ export function websiteSearchIncludeInHeader(
458458
) {
459459
// Generates a script tag that contains the options for configuring search
460460
// which is ready in quarto-search.js
461-
const websiteSearchScript = temp.createFile({ suffix: "html" });
461+
const websiteSearchScript = temp.createFile({ suffix: "-search.html" });
462462
const options = searchOptions(project) || {} as SearchOptions;
463463
options[kLanguageDefaults] = {} as FormatLanguage;
464464
Object.keys(format.language).forEach((key) => {

src/resources/filters/quarto-pre/includes.lua

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,21 @@ function readIncludeFiles(meta, includes, target)
4848
-- process include files
4949
local files = param(includes, {})
5050
for _,file in ipairs(files) do
51-
-- read file contents
52-
local f = io.open(pandoc.utils.stringify(file), "r")
53-
local contents = f:read("*all")
54-
f:close()
55-
-- write as as raw include
56-
addInclude(meta, FORMAT, target, contents)
51+
52+
local status, err = pcall(function ()
53+
-- read file contents
54+
local f = io.open(pandoc.utils.stringify(file), "r")
55+
local contents = f:read("*all")
56+
f:close()
57+
-- write as as raw include
58+
addInclude(meta, FORMAT, target, contents)
59+
dump(file)
60+
end)
61+
62+
if not status then
63+
dump("FAILED TO READ FILE " .. file)
64+
error(err)
65+
end
5766
end
5867

5968

0 commit comments

Comments
 (0)