Skip to content

Commit 552106e

Browse files
cdervgithub-actions[bot]
authored andcommitted
Fix reference.ts producing empty hugo.json (#1957)
Hugo is a custom Quarto format not in pandoc-all, so optionsForFormat("hugo") matches no options and writes []. Map "hugo" to its base format "gfm" for option lookup while keeping the output filename as hugo.json. Also add a guard that warns and skips formats with no pandoc-all match. (cherry picked from commit 3468104)
1 parent c6ea2fe commit 552106e

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

tools/reference.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ const readSchema = (file: string) => {
2020
// deno-lint-ignore no-explicit-any
2121
const formatAliases = (readSchema("format-aliases.yml") as any)["aliases"] as Record<string, string[]>;
2222
const allFormats = formatAliases["pandoc-all"];
23+
24+
// Custom Quarto formats not in pandoc-all, mapped to their base Pandoc format
25+
const customFormatAliases: Record<string, string> = {
26+
"hugo": "gfm",
27+
};
28+
2329
const resolveFormats = (formats: string[]): string[] => {
2430
return distinct(formats
2531
.reduce((formats, format) => {
@@ -171,7 +177,12 @@ const writeDocumentOptions = (format: string, path: string) => {
171177
for (const file of expandGlobSync("docs/reference/formats/**/*.qmd")) {
172178
if (file.isFile) {
173179
const format = basename(file.name, ".qmd");
174-
writeDocumentOptions(format, join(dirname(file.path), format + ".json"));
180+
const lookupFormat = customFormatAliases[format] ?? format;
181+
if (!allFormats.includes(lookupFormat)) {
182+
console.warn(`Warning: format "${format}" not in pandoc-all and has no custom alias. Skipping.`);
183+
continue;
184+
}
185+
writeDocumentOptions(lookupFormat, join(dirname(file.path), format + ".json"));
175186
}
176187
}
177188

0 commit comments

Comments
 (0)