Skip to content
Merged
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
40 changes: 22 additions & 18 deletions src/project/project-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ import { refSchema } from "../core/lib/yaml-schema/common.ts";
import { Brand as BrandJson } from "../resources/types/schema-types.ts";
import { Brand } from "../core/brand/brand.ts";
import { warnOnce } from "../core/log.ts";
import { assert } from "testing/asserts";

export function projectExcludeDirs(context: ProjectContext): string[] {
const outputDir = projectOutputDir(context);
Expand Down Expand Up @@ -556,25 +557,28 @@ export async function projectResolveBrand(
if (fileInformation.brand) {
return fileInformation.brand;
}
if (typeof metadata.brand !== "string") {
warnOnce(
`Brand metadata must be a filename, but is of type ${typeof metadata
.brand} in file ${fileName}. Will ignore brand information`,
);
return project.resolveBrand();
}
let brandPath: string = "";
if (brandPath.startsWith("/")) {
brandPath = join(project.dir, metadata.brand);
if (typeof metadata.brand === "string") {
let brandPath: string = "";
if (brandPath.startsWith("/")) {
brandPath = join(project.dir, metadata.brand);
} else {
brandPath = join(dirname(fileName), metadata.brand);
}
const brand = await readAndValidateYamlFromFile(
brandPath,
refSchema("brand", "Format-independent brand configuration."),
"Brand validation failed for " + brandPath + ".",
) as BrandJson;
fileInformation.brand = new Brand(brand, dirname(brandPath), project.dir);
return fileInformation.brand;
} else {
brandPath = join(dirname(fileName), metadata.brand);
assert(typeof metadata.brand === "object");
fileInformation.brand = new Brand(
metadata.brand as BrandJson,
dirname(fileName),
project.dir,
);
return fileInformation.brand;
}
const brand = await readAndValidateYamlFromFile(
brandPath,
refSchema("brand", "Format-independent brand configuration."),
"Brand validation failed for " + brandPath + ".",
) as BrandJson;
fileInformation.brand = new Brand(brand, dirname(brandPath), project.dir);
return fileInformation.brand;
}
}
21 changes: 17 additions & 4 deletions src/resources/editor/tools/vs-code.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -16628,6 +16628,19 @@ var require_yaml_intelligence_resources = __commonJS({
schema: "path",
description: "Use the specified file as a style reference in producing a docx, \npptx, or odt file.\n"
},
{
name: "brand",
schema: {
anyOf: [
"string",
"boolean",
{
ref: "brand"
}
]
},
description: "Branding information to use for this document. If a string, the path to a brand file.\nIf false, don't use branding on this document. If an object, an inline brand\ndefinition.\n"
},
{
name: "theme",
tags: {
Expand Down Expand Up @@ -22618,7 +22631,7 @@ var require_yaml_intelligence_resources = __commonJS({
"The page layout to use for this document (<code>article</code>,\n<code>full</code>, or <code>custom</code>)",
{
short: "Target page width for output (used to compute columns widths for\n<code>layout</code> divs)",
long: "Target page width for output (used to compute columns widths for\n<code>layout</code> divs). Defaults to 6.5 inches, which corresponds to\ndefault letter page settings in docx and odt."
long: "Target body page width for output (used to compute columns widths for\n<code>layout</code> divs). Defaults to 6.5 inches, which corresponds to\ndefault letter page settings in docx and odt (8.5 inches with 1 inch for\neach margins)."
},
{
short: "Properties of the grid system used to layout Quarto HTML pages.",
Expand Down Expand Up @@ -24118,12 +24131,12 @@ var require_yaml_intelligence_resources = __commonJS({
mermaid: "%%"
},
"handlers/mermaid/schema.yml": {
_internalId: 192600,
_internalId: 193258,
type: "object",
description: "be an object",
properties: {
"mermaid-format": {
_internalId: 192592,
_internalId: 193250,
type: "enum",
enum: [
"png",
Expand All @@ -24139,7 +24152,7 @@ var require_yaml_intelligence_resources = __commonJS({
exhaustiveCompletions: true
},
theme: {
_internalId: 192599,
_internalId: 193257,
type: "anyOf",
anyOf: [
{
Expand Down
21 changes: 17 additions & 4 deletions src/resources/editor/tools/yaml/web-worker.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 17 additions & 4 deletions src/resources/editor/tools/yaml/yaml-intelligence-resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -9600,6 +9600,19 @@
"schema": "path",
"description": "Use the specified file as a style reference in producing a docx, \npptx, or odt file.\n"
},
{
"name": "brand",
"schema": {
"anyOf": [
"string",
"boolean",
{
"ref": "brand"
}
]
},
"description": "Branding information to use for this document. If a string, the path to a brand file.\nIf false, don't use branding on this document. If an object, an inline brand\ndefinition.\n"
},
{
"name": "theme",
"tags": {
Expand Down Expand Up @@ -15590,7 +15603,7 @@
"The page layout to use for this document (<code>article</code>,\n<code>full</code>, or <code>custom</code>)",
{
"short": "Target page width for output (used to compute columns widths for\n<code>layout</code> divs)",
"long": "Target page width for output (used to compute columns widths for\n<code>layout</code> divs). Defaults to 6.5 inches, which corresponds to\ndefault letter page settings in docx and odt."
"long": "Target body page width for output (used to compute columns widths for\n<code>layout</code> divs). Defaults to 6.5 inches, which corresponds to\ndefault letter page settings in docx and odt (8.5 inches with 1 inch for\neach margins)."
},
{
"short": "Properties of the grid system used to layout Quarto HTML pages.",
Expand Down Expand Up @@ -17090,12 +17103,12 @@
"mermaid": "%%"
},
"handlers/mermaid/schema.yml": {
"_internalId": 192600,
"_internalId": 193258,
"type": "object",
"description": "be an object",
"properties": {
"mermaid-format": {
"_internalId": 192592,
"_internalId": 193250,
"type": "enum",
"enum": [
"png",
Expand All @@ -17111,7 +17124,7 @@
"exhaustiveCompletions": true
},
"theme": {
"_internalId": 192599,
"_internalId": 193257,
"type": "anyOf",
"anyOf": [
{
Expand Down
11 changes: 11 additions & 0 deletions src/resources/schema/document-options.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,17 @@
Use the specified file as a style reference in producing a docx,
pptx, or odt file.

- name: brand
schema:
anyOf:
- string # a file path
- boolean # if false, don't use branding on this document
- ref: brand # an inline brand object definition
description: |
Branding information to use for this document. If a string, the path to a brand file.
If false, don't use branding on this document. If an object, an inline brand
definition.

- name: theme
tags:
formats: [$html-doc, revealjs, beamer, dashboard]
Expand Down
1 change: 1 addition & 0 deletions tests/docs/smoke-all/2024/10/29/feature-11192/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
17 changes: 17 additions & 0 deletions tests/docs/smoke-all/2024/10/29/feature-11192/_quarto.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
project:
type: website

website:
title: "feature-11192"
navbar:
left:
- href: index.qmd
text: Home

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



24 changes: 24 additions & 0 deletions tests/docs/smoke-all/2024/10/29/feature-11192/index.qmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
title: "feature-11192"
brand:
color:
palette:
white: '#eeddcc'
black: '#112233'
primary: red
background: black
foreground: white
format: html
_quarto:
tests:
html:
ensureFileRegexMatches:
- ['<p>#eeddcc</p>']
- []
---

{{< brand color white >}}

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/29/feature-11192/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/* css styles */
Loading