Skip to content
Draft
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
2 changes: 1 addition & 1 deletion src/command/render/render-shared.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
4 changes: 2 additions & 2 deletions src/project/project-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) => {
Expand All @@ -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) =>
Expand Down
13 changes: 10 additions & 3 deletions src/project/types/single-file/single-file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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<ProjectContext> {
const environmentMemoizer = makeProjectEnvironmentMemoizer(notebookContext);
const temp = globalTempContext();
Expand All @@ -57,7 +58,7 @@ export async function singleFileProjectContext(
) => {
return fileExecutionEngineAndTarget(
file,
flags,
renderOptions?.flags,
result,
);
},
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
Original file line number Diff line number Diff line change
@@ -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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -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"
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
title: test brand extension
format:
dashboard: default
revealjs: default
typst:
output-ext: typ
_quarto:
tests:
dashboard:
ensureFileRegexMatches:
-
- '<img src="_extensions(/|\\)my-brand(/|\\)sun-face\.png" alt="sun face" class=".*light-content.*">'
- '<img src="_extensions(/|\\)my-brand(/|\\)moon-face\.png" alt="moon face" class=".*dark-content.*">'
- []
revealjs:
ensureFileRegexMatches:
-
- '<img src="_extensions(/|\\)my-brand(/|\\)sun-face\.png" alt="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)
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/.quarto/
Original file line number Diff line number Diff line change
@@ -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

Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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 >}}

Loading