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
10 changes: 5 additions & 5 deletions src/core/brand/brand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ import {
Brand as BrandJson,
BrandFont,
BrandLogoExplicitResource,
BrandNamedLogo,
BrandNamedThemeColor,
BrandStringLightDark,
BrandTypography,
BrandTypographyOptionsBase,
BrandTypographyOptionsHeadings,
} from "../../resources/types/schema-types.ts";
import { InternalError } from "../lib/error.ts";

import { join, relative } from "../../deno_ral/path.ts";

// we can't programmatically convert typescript types to string arrays,
// so we have to define this manually. They should match `BrandNamedThemeColor` in schema-types.ts

Expand Down Expand Up @@ -237,14 +237,14 @@ export class Brand {
if (!entry) {
return { path: name };
}
const pathPrefix = relative(this.projectDir, this.brandDir);
if (typeof entry === "string") {
return { path: entry };
return { path: join(pathPrefix, entry) };
}
entry.path = join(pathPrefix, entry.path);
return entry;
}

// the same implementation as getColor except we can also return {light,dark}
// assuming for now that with only contains strings, not {light,dark}
getLogo(name: "small" | "medium" | "large"): CanonicalLogoInfo | undefined {
const entry = this.data.logo?.[name];
if (!entry) {
Expand Down
9 changes: 7 additions & 2 deletions src/resources/filters/quarto-post/typst-brand-yaml.lua
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,18 @@ function render_typst_brand_yaml()
location_to_typst_align(logoOptions.location) or 'left+top'
quarto.log.debug('logo options', logoOptions)
local altProp = logoOptions.alt and (', alt: "' .. logoOptions.alt .. '"') or ''
local dblbackslash = string.gsub(logoOptions.path, '\\', '\\\\') -- double backslash?
quarto.doc.include_text('in-header',
'#set page(background: align(' .. logoOptions.location .. ', box(inset: ' .. logoOptions.padding .. ', image("' .. logoOptions.path .. '", width: ' .. logoOptions.width .. altProp .. '))))')
'#set page(background: align(' .. logoOptions.location .. ', box(inset: ' .. logoOptions.padding .. ', image("' .. dblbackslash .. '", width: ' .. logoOptions.width .. altProp .. '))))')
end
end
end,
Meta = function(meta)
meta.brand = meta.brand or {typography = {}}
-- it can contain the path but we want to store an object here
if not meta.brand or pandoc.utils.type(meta.brand) == 'Inlines' then
meta.brand = {}
end
meta.brand.typography = meta.brand.typography or {}
local base = _quarto.modules.brand.get_typography('base')
if base and next(base) then
meta.brand.typography.base = {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
title: logo background
brand: brand_yaml/quarto-brand.yml
format:
typst:
keep-typ: true
logo:
padding: 2rem
_quarto:
tests:
typst:
ensureTypstFileRegexMatches:
-
- '#set page\(background: align\(center\+top, box\(inset: 2em, image\("brand_yaml(/|\\\\)resources(/|\\\\)quarto.png", width: 225pt\)\)\)\)'
- []
---

{{< lipsum 4 >}}

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
logo:
images:
large-light: resources/quarto.png
large: large-light
defaults:
quarto:
format:
typst:
logo:
src: large
location: center-top
width: 300px
padding: 1in
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,35 @@
---
title: title is `#context text.font`{=typst} `#context text.weight`{=typst} `#context text.style`{=typst} `#context text.size`{=typst}
format: typst
brand: branding/brand.yml
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 >}}

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.
Loading