diff --git a/src/command/render/render-shared.ts b/src/command/render/render-shared.ts index 1783e4a0d44..d473b2d711d 100644 --- a/src/command/render/render-shared.ts +++ b/src/command/render/render-shared.ts @@ -98,7 +98,7 @@ export async function render( assert(!context, "Expected no context here"); // NB: singleFileProjectContext is currently not fully-featured - context = await singleFileProjectContext(path, nbContext, options.flags); + context = await singleFileProjectContext(path, nbContext, options); // otherwise it's just a file render const result = await renderFiles( diff --git a/src/project/project-context.ts b/src/project/project-context.ts index 0049122c79d..9cc4f86a534 100644 --- a/src/project/project-context.ts +++ b/src/project/project-context.ts @@ -109,7 +109,7 @@ import { onCleanup } from "../core/cleanup.ts"; import { once } from "../core/once.ts"; import { Zod } from "../resources/types/zod/schema-types.ts"; -const mergeExtensionMetadata = async ( +export const mergeExtensionMetadata = async ( context: ProjectContext, pOptions: RenderOptions, ) => { @@ -119,7 +119,7 @@ const mergeExtensionMetadata = async ( const extensions = await pOptions.services.extension.extensions( undefined, context.config, - context.isSingleFile ? undefined : context.dir, + context.dir, { builtIn: false }, ); const projectMetadata = extensions.filter((extension) => diff --git a/src/project/types/single-file/single-file.ts b/src/project/types/single-file/single-file.ts index 9f4f415f431..46b29935156 100644 --- a/src/project/types/single-file/single-file.ts +++ b/src/project/types/single-file/single-file.ts @@ -16,7 +16,7 @@ import { NotebookContext } from "../../../render/notebook/notebook-types.ts"; import { makeProjectEnvironmentMemoizer } from "../../project-environment.ts"; import { ProjectContext } from "../../types.ts"; import { renderFormats } from "../../../command/render/render-contexts.ts"; -import { RenderFlags } from "../../../command/render/types.ts"; +import { RenderFlags, RenderOptions } from "../../../command/render/types.ts"; import { MappedString } from "../../../core/mapped-text.ts"; import { fileExecutionEngineAndTarget } from "../../../execute/engine.ts"; import { @@ -30,11 +30,12 @@ import { ExecutionEngine } from "../../../execute/types.ts"; import { createProjectCache } from "../../../core/cache/cache.ts"; import { globalTempContext } from "../../../core/temp.ts"; import { once } from "../../../core/once.ts"; +import { mergeExtensionMetadata } from "../../project-context.ts"; export async function singleFileProjectContext( source: string, notebookContext: NotebookContext, - flags?: RenderFlags, + renderOptions?: RenderOptions, ): Promise { const environmentMemoizer = makeProjectEnvironmentMemoizer(notebookContext); const temp = globalTempContext(); @@ -57,7 +58,7 @@ export async function singleFileProjectContext( ) => { return fileExecutionEngineAndTarget( file, - flags, + renderOptions?.flags, result, ); }, @@ -86,6 +87,12 @@ export async function singleFileProjectContext( result.diskCache.close(); }), }; + if (renderOptions) { + result.config = { + project: {}, + }; + await mergeExtensionMetadata(result, renderOptions); + } // because the single-file project is cleaned up with // the global text context, we don't need to register it // in the same way that we need to register the multi-file diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/.gitignore b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/.gitignore new file mode 100644 index 00000000000..075b2542afb --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/.gitignore @@ -0,0 +1 @@ +/.quarto/ diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/_extension.yml b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/_extension.yml new file mode 100644 index 00000000000..2d5882388ab --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/_extension.yml @@ -0,0 +1,8 @@ +title: My-brand +author: Gordon Woodhull +version: 1.0.0 +quarto-required: ">=99.9.0" +contributes: + metadata: + project: + brand: mybrand.yml diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/moon-face.png b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/moon-face.png new file mode 100644 index 00000000000..ee057e972b9 Binary files /dev/null and b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/moon-face.png differ diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/mybrand.yml b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/mybrand.yml new file mode 100644 index 00000000000..8cc770035f7 --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/mybrand.yml @@ -0,0 +1,18 @@ +logo: + images: + sun: + path: sun-face.png + alt: sun face + moon: + path: moon-face.png + alt: moon face + medium: + light: sun + dark: moon +color: + background: + light: "#def" + dark: "#042" + foreground: + light: "#411" + dark: "#ffe" diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/sun-face.png b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/sun-face.png new file mode 100644 index 00000000000..62a734cb8db Binary files /dev/null and b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/_extensions/my-brand/sun-face.png differ diff --git a/tests/docs/smoke-all/brand/logo/logo-extension-no-project/logo-brand-extension.qmd b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/logo-brand-extension.qmd new file mode 100644 index 00000000000..ef6eda677bf --- /dev/null +++ b/tests/docs/smoke-all/brand/logo/logo-extension-no-project/logo-brand-extension.qmd @@ -0,0 +1,40 @@ +--- +title: test brand extension +format: + dashboard: default + revealjs: default + typst: + output-ext: typ +_quarto: + tests: + dashboard: + ensureFileRegexMatches: + - + - 'sun face' + - 'moon face' + - [] + revealjs: + ensureFileRegexMatches: + - + - 'sun face' + - + - 'moon-face' + typst: + ensureTypstFileRegexMatches: + - + - 'background: align\(left\+top, box\(inset: 0.75in, image\("_extensions(/|\\\\)my-brand(/|\\\\)sun-face.png", width: 1\.5in, alt: "sun face"\)\)' + - + - 'image.*moon-face' +--- + +# brand.yml extension + +Here is some inline code `def foo(x): return x`{.python} and `y`{.python} and `z`{.python}. + + +{{< lipsum 1 >}} + +```{.python} +# | echo: true +print(1+2) +``` diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/.gitignore b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/.gitignore new file mode 100644 index 00000000000..075b2542afb --- /dev/null +++ b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/.gitignore @@ -0,0 +1 @@ +/.quarto/ diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/_extension.yml b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/_extension.yml new file mode 100644 index 00000000000..106a96726ca --- /dev/null +++ b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/_extension.yml @@ -0,0 +1,9 @@ +title: Typst-brand-typography-example +author: Gordon Woodhull +version: 1.0.0 +quarto-required: ">=99.9.0" +contributes: + metadata: + project: + brand: brand.yml + diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/brand.yml b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/brand.yml new file mode 100644 index 00000000000..0fed9b28e9e --- /dev/null +++ b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/brand.yml @@ -0,0 +1,27 @@ +typography: + fonts: + - family: "Open Sans" + source: file + files: + - resources/fonts/opensans/OpenSans-VariableFont_wdth,wght.ttf + - family: "Fira Code" + source: file + files: + - resources/fonts/firacode/FiraCode-VF.ttf + - family: "Roboto Slab" + source: file + files: + - path: resources/fonts/robotoslab/RobotoSlab-VariableFont_wght.ttf + weight: 600 + style: normal + base: + family: Open Sans + line-height: 1.25em + size: 1rem + headings: + family: Roboto Slab + color: primary + weight: 600 + monospace: + family: Fira Code + size: 0.9em diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/firacode/FiraCode-VF.ttf b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/firacode/FiraCode-VF.ttf new file mode 100644 index 00000000000..c05ac827c58 Binary files /dev/null and b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/firacode/FiraCode-VF.ttf differ diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/opensans/OpenSans-VariableFont_wdth,wght.ttf b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/opensans/OpenSans-VariableFont_wdth,wght.ttf new file mode 100644 index 00000000000..ac587b482b8 Binary files /dev/null and b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/opensans/OpenSans-VariableFont_wdth,wght.ttf differ diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/robotoslab/RobotoSlab-VariableFont_wght.ttf b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/robotoslab/RobotoSlab-VariableFont_wght.ttf new file mode 100644 index 00000000000..d78883c1283 Binary files /dev/null and b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/_extensions/typst-brand-typography-example/resources/fonts/robotoslab/RobotoSlab-VariableFont_wght.ttf differ diff --git a/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/brand-typography.qmd b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/brand-typography.qmd new file mode 100644 index 00000000000..a5989c6fd97 --- /dev/null +++ b/tests/docs/smoke-all/typst/brand-yaml/typography/brand-extension-no-project/brand-typography.qmd @@ -0,0 +1,34 @@ +--- +title: title is `#context text.font`{=typst} `#context text.weight`{=typst} `#context text.style`{=typst} `#context text.size`{=typst} +format: typst +include-in-header: + text: | + #set text(fallback: false) +_quarto: + tests: + typst: + ensurePdfRegexMatches: + - + - 'title is roboto slab semibold normal 16.5pt' + - 'heading-2 is roboto slab semibold normal 15.4pt' + - 'paragraph is open sans regular normal 11pt' + - 'fib = num => num < 2' + - [] +--- + +## heading-2 is `#context text.font`{=typst} `#context text.weight`{=typst} `#context text.style`{=typst} `#context text.size`{=typst} + +paragraph is `#context text.font`{=typst} `#context text.weight`{=typst} `#context text.style`{=typst} `#context text.size`{=typst}. + +```{=typst} +#block(text(font: "Fira Code", weight: "black")[Some text with font set explicitly to #context text.font #context text.weight #context text.style #context text.size]) + +``` + +``` +const fib = num => num < 2 ? num : fib(num-1) + fib(num - 2); +console.log(fib(12)) +``` + +{{< lipsum 3 >}} +