Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions src/command/render/pandoc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ import {
MarkdownPipelineHandler,
} from "../../core/markdown-pipeline.ts";
import { getEnv } from "../../../package/src/util/utils.ts";
import { is } from "https://cdn.skypack.dev/-/[email protected]/dist=es2019,mode=imports/optimized/css-select.js";

// in case we are running multiple pandoc processes
// we need to make sure we capture all of the trace files
Expand Down Expand Up @@ -993,25 +994,29 @@ export async function runPandoc(
const pandocMetadata = ld.cloneDeep(options.format.metadata || {});
for (const key of Object.keys(engineMetadata)) {
const isChapterTitle = key === kTitle && projectIsBook(options.project);
// if it's standard pandoc metadata and NOT contained in a format specific
// override then use the engine metadata value
if (isQuartoMetadata(key) || isChapterTitle || isIncludeMetadata(key)) {
continue;
}

if (!isQuartoMetadata(key) && !isChapterTitle && !isIncludeMetadata(key)) {
// if it's standard pandoc metadata and NOT contained in a format specific
// override then use the engine metadata value

// don't do if they've overridden the value in a format
const formats = engineMetadata[kMetadataFormat] as Metadata;
if (ld.isObject(formats) && metadataGetDeep(formats, key).length > 0) {
continue;
}
// don't do if they've overridden the value in a format
const formats = engineMetadata[kMetadataFormat] as Metadata;
if (ld.isObject(formats) && metadataGetDeep(formats, key).length > 0) {
continue;
}

// don't process some format specific metadata that may have been processed already
// - theme is handled specifically already for revealjs with a metadata override and should not be overridden by user input
if (key === kTheme && isRevealjsOutput(options.format.pandoc)) {
continue;
}
// perform the override
pandocMetadata[key] = engineMetadata[key];
// don't process some format specific metadata that may have been processed already
// - theme is handled specifically already for revealjs with a metadata override and should not be overridden by user input
if (key === kTheme && isRevealjsOutput(options.format.pandoc)) {
continue;
}

// perform the override
pandocMetadata[key] = mergeConfigs(
pandocMetadata[key],
engineMetadata[key],
);
}

// Resolve any date fields
Expand Down
6 changes: 3 additions & 3 deletions src/core/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ import * as ld from "./lodash.ts";

export function mergeConfigs<T>(config: T, ...configs: Array<unknown>): T {
// copy all configs so we don't mutate them
config = ld.cloneDeep(config);
configs = ld.cloneDeep(configs);
config = ld.cloneDeep({ foo: config });
configs = ld.cloneDeep(configs.map((x) => ({ foo: x })));

return ld.mergeWith(
config,
...configs,
mergeArrayCustomizer,
);
).foo;
}

export function mergeArrayCustomizer(objValue: unknown, srcValue: unknown) {
Expand Down
1 change: 1 addition & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
22 changes: 22 additions & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/.luarc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"Generator": [
"Quarto",
"This file provides type information for Lua completion and diagnostics.",
"Quarto will automatically update this file to reflect the current path",
"of your Quarto installation, and the file will also be added to .gitignore",
"since it points to the absolute path of Quarto on the local system.",
"Remove the 'Generator' key to manage this file's contents manually."
],
"Lua.runtime.version": "Lua 5.3",
"Lua.workspace.checkThirdParty": false,
"Lua.workspace.library": [
"/Users/cscheid/repos/github/quarto-dev/quarto-cli/src/resources/lua-types"
],
"Lua.runtime.plugin": "/Users/cscheid/repos/github/quarto-dev/quarto-cli/src/resources/lua-plugin/plugin.lua",
"Lua.completion.showWord": "Disable",
"Lua.completion.keywordSnippet": "Both",
"Lua.diagnostics.disable": [
"lowercase-global",
"trailing-space"
]
}
20 changes: 20 additions & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
project:
type: website

website:
title: "This is the website title"
navbar:
left:
- href: index.qmd
text: Home
- about.qmd

format:
html:
theme: cosmo
css: styles.css
toc: true

mymeta:
key1: value1
key2: value2
5 changes: 5 additions & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/about.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: "About"
---

About this site
11 changes: 11 additions & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
title: "This is the page title"
filters:
- test.lua
mymeta:
key1: override
---

This is a Quarto website.

To learn more about Quarto websites visit <https://quarto.org/docs/websites>.
1 change: 1 addition & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* css styles */
8 changes: 8 additions & 0 deletions tests/docs/smoke-all/2024/10/21/issue-11138/test.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
function Meta(m)
if pandoc.utils.stringify(m.mymeta.key1) ~= "override" then
crash()
end
if pandoc.utils.stringify(m.mymeta.key2) ~= "value2" then
crash()
end
end
Loading