Skip to content

Commit f1ea97d

Browse files
choose light or dark brand for Typst
wip: - needs better name - some lingering cases in typst_css where it needs access to choose-brand instead of hard-coded brandMode - needs tests
1 parent d52d6e7 commit f1ea97d

File tree

4 files changed

+12
-2
lines changed

4 files changed

+12
-2
lines changed

src/command/render/filters.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { existsSync } from "../../deno_ral/fs.ts";
99
import {
1010
kBibliography,
1111
kBrand,
12+
kChooseBrand,
1213
kCitationLocation,
1314
kCiteMethod,
1415
kClearCellOptions,
@@ -909,6 +910,7 @@ const extractTypstFilterParams = (format: Format) => {
909910
[kTocIndent]: format.metadata[kTocIndent],
910911
[kLogo]: format.metadata[kLogo],
911912
[kCssPropertyProcessing]: format.metadata[kCssPropertyProcessing],
913+
[kChooseBrand]: format.metadata[kChooseBrand],
912914
[kHtmlPreTagProcessing]: format.metadata[kHtmlPreTagProcessing],
913915
};
914916
};

src/config/constants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ export const kFontPaths = "font-paths";
141141
export const kHtmlTableProcessing = "html-table-processing";
142142
export const kHtmlPreTagProcessing = "html-pre-tag-processing";
143143
export const kCssPropertyProcessing = "css-property-processing";
144+
export const kChooseBrand = "choose-brand"
144145
export const kUseRsvgConvert = "use-rsvg-convert";
145146
export const kValidateYaml = "validate-yaml";
146147

src/resources/filters/quarto-post/cell-renderings.lua

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ function choose_cell_renderings()
4747
if quarto.format.isHtmlOutput() and lightDiv and darkDiv then
4848
blocks:insert(pandoc.Div(lightDiv.content, pandoc.Attr("", {'light-content'}, {})))
4949
blocks:insert(pandoc.Div(darkDiv.content, pandoc.Attr("", {'dark-content'}, {})))
50+
elseif quarto.format.isTypstOutput() and lightDiv and darkDiv then
51+
local brandMode = param('choose-brand') or 'light'
52+
if brandMode == 'light' then
53+
blocks:insert(lightDiv)
54+
elseif brandMode == 'dark' then
55+
blocks:insert(darkDiv)
56+
end
5057
else
5158
blocks:insert(lightDiv or darkDiv)
5259
end

src/resources/filters/quarto-post/typst-brand-yaml.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function render_typst_brand_yaml()
5959
return {
6060
Pandoc = function(pandoc0)
6161
local brand = param('brand')
62-
local brandMode = 'light'
62+
local brandMode = param('choose-brand') or 'light'
6363
brand = brand and brand[brandMode]
6464
if brand and brand.processedData then
6565
-- color
@@ -300,7 +300,7 @@ function render_typst_brand_yaml()
300300
end
301301
end,
302302
Meta = function(meta)
303-
local brandMode = 'light'
303+
local brandMode = param('choose-brand') or 'light'
304304
-- it can contain the path but we want to store an object here
305305
if not meta.brand or pandoc.utils.type(meta.brand) == 'Inlines' then
306306
meta.brand = {}

0 commit comments

Comments
 (0)