Skip to content

Commit b81145d

Browse files
committed
feat: add skylighting-fix option
1 parent 1ae18ea commit b81145d

2 files changed

Lines changed: 18 additions & 2 deletions

File tree

_extensions/code-window/_schema.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ options:
1818
type: string
1919
default: "code-window"
2020
description: "Typst wrapper function name for code-window rendering."
21+
skylighting-fix:
22+
type: boolean
23+
default: true
24+
description: "Enable or disable the Skylighting hot-fix for Typst output (overrides block styling and adds inline code background)."

_extensions/code-window/code-window.lua

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ local utils = require(quarto.utils.resolve_path('_modules/utils.lua'):gsub('%.lu
2424
--- @field auto_filename boolean Whether to auto-generate filename from language
2525
--- @field style string Window decoration style ('macos', 'windows', 'default')
2626
--- @field typst_wrapper string Typst wrapper function name
27+
--- @field skylighting_fix boolean Whether to apply the Skylighting hot-fix for Typst
2728

2829
local VALID_STYLES = { ['default'] = true, ['macos'] = true, ['windows'] = true }
2930

@@ -32,6 +33,7 @@ local DEFAULTS = {
3233
['auto-filename'] = 'true',
3334
['style'] = 'macos',
3435
['wrapper'] = 'code-window',
36+
['skylighting-fix'] = 'true',
3537
}
3638

3739
local CURRENT_FORMAT = nil
@@ -329,7 +331,7 @@ function Meta(meta)
329331
CURRENT_FORMAT = utils.get_quarto_format()
330332
local opts = utils.get_options({
331333
extension = EXTENSION_NAME,
332-
keys = { 'enabled', 'auto-filename', 'style', 'wrapper' },
334+
keys = { 'enabled', 'auto-filename', 'style', 'wrapper', 'skylighting-fix' },
333335
meta = meta,
334336
defaults = DEFAULTS,
335337
})
@@ -344,6 +346,7 @@ function Meta(meta)
344346
auto_filename = opts['auto-filename'] == 'true',
345347
style = VALID_STYLES[opts['style']] and opts['style'] or 'macos',
346348
typst_wrapper = opts['wrapper'],
349+
skylighting_fix = opts['skylighting-fix'] == 'true',
347350
}
348351

349352
if CURRENT_FORMAT == 'html' and CONFIG.enabled then
@@ -435,7 +438,16 @@ local filters = {
435438
}
436439

437440
for _, subfilter in ipairs(load_skylighting_hotfix_filters()) do
438-
table.insert(filters, subfilter)
441+
local wrapped = {}
442+
for element_type, handler in pairs(subfilter) do
443+
wrapped[element_type] = function(...)
444+
if not CONFIG or not CONFIG.skylighting_fix then
445+
return nil
446+
end
447+
return handler(...)
448+
end
449+
end
450+
table.insert(filters, wrapped)
439451
end
440452

441453
return filters

0 commit comments

Comments
 (0)