(id: string, payload: string, { persistentCache })
| 23 | config = _config; |
| 24 | }, |
| 25 | transform(id: string, payload: string, { persistentCache }) { |
| 26 | if (lang) { |
| 27 | if (lang.startsWith("mermaid")) { |
| 28 | if (config.renderMermaid) { |
| 29 | mermaidGraphs.push({ code, lang }); |
| 30 | payload = "<GRAPH></GRAPH>"; |
| 31 | } |
| 32 | } else if (lang.startsWith("katex")) { |
| 33 | if (config.renderKatex) |
| 34 | payload = katexRenderer(code, { |
| 35 | type: lang, |
| 36 | inlineRender: id === "codespan", |
| 37 | config, |
| 38 | persistentCache, |
| 39 | }); |
| 40 | } else { |
| 41 | let keyValue: string | string[] = []; |
| 42 | let options: Record<string, string> = { lang }; |
| 43 | if (lang.includes(" ")) { |
| 44 | [lang, ...keyValue] = lang.split(" "); |
| 45 | options = { ...JSON.parse(keyValue.join(" ")) }; |
| 46 | } |
| 47 | try { |
| 48 | if (options.include) { |
| 49 | payload = renderTwoSlash({ |
| 50 | persistentCache, |
| 51 | code, |
| 52 | highlighter, |
| 53 | lang, |
| 54 | options, |
| 55 | entryId: options.include, |
| 56 | }); |
| 57 | } else if (options.name) { |
| 58 | addMainIncludeTwoSlash(code, options.name); |
| 59 | payload = ""; |
| 60 | } else { |
| 61 | payload = renderShiki({ |
| 62 | persistentCache, |
| 63 | highlighter, |
| 64 | code, |
| 65 | lang, |
| 66 | options, |
| 67 | }); |
| 68 | } |
| 69 | } catch {} |
| 70 | } |
| 71 | code = lang = ""; |
| 72 | return payload; |
| 73 | } |
| 74 | }, |
| 75 | tapArgs(id: string, args: any[]) { |
| 76 | if (id === "code") { |
| 77 | code = args[0]; |
nothing calls this directly
no test coverage detected