@@ -239,102 +239,103 @@ function render_typst_brand_yaml()
239
239
' , content)'
240
240
}))
241
241
end
242
-
243
- -- logo
244
- local logo = param (' logo' )
245
- local logoOptions = {}
246
- local foundLogo = null
247
- if logo then
248
- if type (logo ) == ' string' then
249
- foundLogo = _quarto .modules .brand .get_logo (brandMode , logo ) or {path = logo }
250
- elseif type (logo ) == ' table' then
251
- for k , v in pairs (logo ) do
252
- logoOptions [k ] = v
253
- end
254
- if logo .path then
255
- foundLogo = _quarto .modules .brand .get_logo (brandMode , logo .path ) or {path = logo }
256
- end
242
+ end
243
+ end ,
244
+ Meta = function (meta )
245
+ local brand = param (' brand' )
246
+ local brandMode = param (' brand-mode' ) or ' light'
247
+ brand = brand and brand [brandMode ]
248
+ -- it can contain the path but we want to store an object here
249
+ if not meta .brand or pandoc .utils .type (meta .brand ) == ' Inlines' then
250
+ meta .brand = {}
251
+ end
252
+ -- logo
253
+ local logo = param (' logo' )
254
+ local logoOptions = {}
255
+ local foundLogo = null
256
+ if logo then
257
+ if type (logo ) == ' string' then
258
+ foundLogo = _quarto .modules .brand .get_logo (brandMode , logo ) or {path = logo }
259
+ elseif type (logo ) == ' table' then
260
+ for k , v in pairs (logo ) do
261
+ logoOptions [k ] = v
262
+ end
263
+ if logo .path then
264
+ foundLogo = _quarto .modules .brand .get_logo (brandMode , logo .path ) or {path = logo }
257
265
end
258
266
end
259
- if not foundLogo and brand . processedData . logo then
260
- local tries = { ' large ' , ' small ' , ' medium ' } -- low to high priority
261
- foundLogo = _quarto .modules .brand .get_logo (brandMode , ' medium' )
262
- or _quarto .modules .brand .get_logo (brandMode , ' small' )
263
- or _quarto .modules .brand .get_logo (brandMode , ' large' )
264
- end
265
- if foundLogo then
266
- logoOptions .path = foundLogo .path
267
- logoOptions .alt = foundLogo .alt
267
+ end
268
+ if not foundLogo and brand and brand . processedData and brand . processedData . logo then
269
+ foundLogo = _quarto .modules .brand .get_logo (brandMode , ' medium' )
270
+ or _quarto .modules .brand .get_logo (brandMode , ' small' )
271
+ or _quarto .modules .brand .get_logo (brandMode , ' large' )
272
+ end
273
+ if foundLogo then
274
+ logoOptions .path = foundLogo .path
275
+ logoOptions .alt = foundLogo .alt
268
276
269
- local pads = {}
270
- for k , v in _quarto .utils .table .sortedPairs (logoOptions ) do
271
- if k == ' padding' then
272
- local widths = {}
273
- _quarto .modules .typst .css .parse_multiple (v , 5 , function (s , start )
274
- local width , newstart = _quarto .modules .typst .css .consume_width (s , start )
275
- table.insert (widths , width )
276
- return newstart
277
- end )
278
- local sides = _quarto .modules .typst .css .expand_side_shorthand (
279
- widths ,
280
- ' widths in padding list: ' .. v )
281
- pads .top = sides .top
282
- pads .right = sides .right
283
- pads .bottom = sides .bottom
284
- pads .left = sides .left
285
- elseif k :find ' ^padding-' then
286
- local _ , ndash = k :gsub (' -' , ' ' )
287
- if ndash == 1 then
288
- local side = k :match (' ^padding--(%a+)' )
289
- local padding_sides = {' left' , ' top' , ' right' , ' bottom' }
290
- if tcontains (padding_sides , side ) then
291
- pads [side ] = _quarto .modules .typst .css .translate_length (v )
292
- else
293
- quarto .log .warning (' invalid padding key ' .. k )
294
- end
277
+ local pads = {}
278
+ for k , v in _quarto .utils .table .sortedPairs (logoOptions ) do
279
+ if k == ' padding' then
280
+ local widths = {}
281
+ _quarto .modules .typst .css .parse_multiple (v , 5 , function (s , start )
282
+ local width , newstart = _quarto .modules .typst .css .consume_width (s , start )
283
+ table.insert (widths , width )
284
+ return newstart
285
+ end )
286
+ local sides = _quarto .modules .typst .css .expand_side_shorthand (
287
+ widths ,
288
+ ' widths in padding list: ' .. v )
289
+ pads .top = sides .top
290
+ pads .right = sides .right
291
+ pads .bottom = sides .bottom
292
+ pads .left = sides .left
293
+ elseif k :find ' ^padding-' then
294
+ local _ , ndash = k :gsub (' -' , ' ' )
295
+ if ndash == 1 then
296
+ local side = k :match (' ^padding--(%a+)' )
297
+ local padding_sides = {' left' , ' top' , ' right' , ' bottom' }
298
+ if tcontains (padding_sides , side ) then
299
+ pads [side ] = _quarto .modules .typst .css .translate_length (v )
295
300
else
296
301
quarto .log .warning (' invalid padding key ' .. k )
297
302
end
298
- end
299
- end
300
- local inset = nil
301
- if next (pads ) then
302
- if pads .top == pads .right and
303
- pads .right == pads .bottom and
304
- pads .bottom == pads .left
305
- then
306
- inset = pads .top
307
- elseif pads .top == pads .bottom and pads .left == pads .right then
308
- inset = _quarto .modules .typst .as_typst_dictionary ({x = pads .left , y = pads .top })
309
303
else
310
- inset = _quarto . modules . typst . as_typst_dictionary ( pads )
304
+ quarto . log . warning ( ' invalid padding key ' .. k )
311
305
end
312
- else
313
- inset = ' 0.75in'
314
306
end
315
- logoOptions .width = _quarto .modules .typst .css .translate_length (logoOptions .width or ' 1.5in' )
316
- logoOptions .location = logoOptions .location and
317
- location_to_typst_align (logoOptions .location ) or ' left+top'
318
- quarto .log .debug (' logo options' , logoOptions )
319
- local altProp = logoOptions .alt and (' , alt: "' .. logoOptions .alt .. ' "' ) or ' '
320
- local imageFilename = logoOptions .path
321
- if _quarto .modules .mediabag .should_mediabag (imageFilename ) then
322
- imageFilename = _quarto .modules .mediabag .resolved_url_cache [logoOptions .path ] or _quarto .modules .mediabag .fetch_and_store_image (logoOptions .path )
323
- imageFilename = _quarto .modules .mediabag .write_mediabag_entry (imageFilename ) or imageFilename
307
+ end
308
+ local inset = nil
309
+ if next (pads ) then
310
+ if pads .top == pads .right and
311
+ pads .right == pads .bottom and
312
+ pads .bottom == pads .left
313
+ then
314
+ inset = pads .top
315
+ elseif pads .top == pads .bottom and pads .left == pads .right then
316
+ inset = _quarto .modules .typst .as_typst_dictionary ({x = pads .left , y = pads .top })
324
317
else
325
- -- backslashes need to be doubled for Windows
326
- imageFilename = string.gsub (imageFilename , ' \\ ' , ' \\\\ ' )
318
+ inset = _quarto .modules .typst .as_typst_dictionary (pads )
327
319
end
328
- quarto .doc .include_text (' in-header' ,
329
- ' #set page(background: align(' .. logoOptions .location .. ' , box(inset: ' .. inset .. ' , image("' .. imageFilename .. ' ", width: ' .. logoOptions .width .. altProp .. ' ))))' )
330
- end
331
- end
332
- end ,
333
- Meta = function (meta )
334
- local brandMode = param (' brand-mode' ) or ' light'
335
- -- it can contain the path but we want to store an object here
336
- if not meta .brand or pandoc .utils .type (meta .brand ) == ' Inlines' then
337
- meta .brand = {}
320
+ else
321
+ inset = ' 0.75in'
322
+ end
323
+ logoOptions .width = _quarto .modules .typst .css .translate_length (logoOptions .width or ' 1.5in' )
324
+ logoOptions .inset = inset
325
+ logoOptions .location = logoOptions .location and
326
+ location_to_typst_align (logoOptions .location ) or ' left+top'
327
+ quarto .log .debug (' logo options' , logoOptions )
328
+ local imageFilename = logoOptions .path
329
+ if _quarto .modules .mediabag .should_mediabag (imageFilename ) then
330
+ imageFilename = _quarto .modules .mediabag .resolved_url_cache [logoOptions .path ] or _quarto .modules .mediabag .fetch_and_store_image (logoOptions .path )
331
+ imageFilename = _quarto .modules .mediabag .write_mediabag_entry (imageFilename ) or imageFilename
332
+ imageFilename = imageFilename and imageFilename :gsub (' \\ _' , ' _' )
333
+ else
334
+ -- backslashes need to be doubled for Windows
335
+ imageFilename = string.gsub (imageFilename , ' \\ ' , ' \\\\ ' )
336
+ end
337
+ logoOptions .path = pandoc .RawInline (' typst' , imageFilename )
338
+ meta .logo = logoOptions
338
339
end
339
340
meta .brand .typography = meta .brand .typography or {}
340
341
local base = _quarto .modules .brand .get_typography (brandMode , ' base' )
0 commit comments