@@ -278,10 +278,11 @@ local TYPST_FUNCTION_DEF = [==[
278278-- ============================================================================
279279
280280--- Process CodeBlock for Typst format.
281- --- Renders through Pandoc's Typst writer to preserve skylighting,
282- --- then wraps the output with the code-window function.
281+ --- Returns a block sandwich: opening RawBlock, the original CodeBlock,
282+ --- and a closing RawBlock. Pandoc's own Typst writer handles Skylighting
283+ --- with the document's theme automatically.
283284--- @param block pandoc.CodeBlock Code block element
284- --- @return pandoc.RawBlock | pandoc.CodeBlock Transformed or original block
285+ --- @return pandoc.List | pandoc.CodeBlock Block list or original block
285286local function process_typst (block )
286287 local block_style = read_block_style (block )
287288 local explicit_filename = block .attributes [' filename' ]
@@ -301,28 +302,17 @@ local function process_typst(block)
301302
302303 local effective_style = block_style or CONFIG .style
303304
304- -- Render through Pandoc's Typst writer to preserve syntax highlighting.
305- -- Pass highlight_method from the document's writer options so the
306- -- user's chosen theme (e.g. github-dark) is respected.
307- local write_opts = nil
308- if PANDOC_WRITER_OPTIONS and PANDOC_WRITER_OPTIONS .highlight_method then
309- write_opts = pandoc .WriterOptions ({
310- highlight_method = PANDOC_WRITER_OPTIONS .highlight_method ,
311- })
312- end
313- local rendered = pandoc .write (pandoc .Pandoc ({ block }), ' typst' , write_opts )
314- rendered = rendered :gsub (' %s+$' , ' ' )
315-
316- local typst_code = string.format (
317- ' #%s(filename: "%s", is-auto: %s, style: "%s")[\n %s\n ]' ,
318- CONFIG .typst_wrapper ,
319- filename :gsub (' "' , ' \\ "' ),
320- is_auto and ' true' or ' false' ,
321- effective_style ,
322- rendered
323- )
324-
325- return pandoc .RawBlock (' typst' , typst_code )
305+ return {
306+ pandoc .RawBlock (' typst' , string.format (
307+ ' #%s(filename: "%s", is-auto: %s, style: "%s")[' ,
308+ CONFIG .typst_wrapper ,
309+ filename :gsub (' "' , ' \\ "' ),
310+ is_auto and ' true' or ' false' ,
311+ effective_style
312+ )),
313+ block ,
314+ pandoc .RawBlock (' typst' , ' ]' ),
315+ }
326316end
327317
328318-- ============================================================================
@@ -425,7 +415,7 @@ function Meta(meta)
425415end
426416
427417--- Process CodeBlock elements.
428- --- Typst: converts blocks to RawBlocks .
418+ --- Typst: wraps blocks with RawBlock sandwich .
429419--- HTML/Reveal.js: wraps blocks with auto-filename Divs.
430420function CodeBlock (block )
431421 if not CURRENT_FORMAT or not CONFIG or not CONFIG .enabled then
0 commit comments