-- caption-code-blocks.luaifFORMAT~="typst"thenreturn{}endlocalfunctionclass_signals_plantuml(c)ifc=='plantuml'orc=='puml'thenreturntrueendifstring.find(c,'{.plantuml',1,true)==1orstring.find(c,'{.puml',1,true)==1thenreturntrueendreturnfalseendlocalfunctionclass_signals_mermaid(c)ifc=='mermaid'thenreturntrueendifstring.find(c,'{.mermaid',1,true)==1thenreturntrueendreturnfalseendfunctionCodeBlock(el)-- When diagram conversion fails, the block stays a CodeBlock; do not wrap it-- in #figure(...) or the preview shows raw ``` fences as "the diagram".for_,cinipairs(el.classes)doifclass_signals_plantuml(c)orclass_signals_mermaid(c)thenreturnnilendendlocalcode=pandoc.write(pandoc.Pandoc({el}),"typst")localcode_before="#figure("localcode_after=")"ifel.attr.attributes["caption"]thencode_after=", caption: ["..el.attr.attributes["caption"].."],\n"..code_afterendif#el.identifier>0thencode_after=code_after.."<"..el.identifier..">"endreturnpandoc.RawBlock("typst",code_before..code..code_after)end