{"record":{"id":"e19040f52eed6caa","repo":"siyuan-note/siyuan","slug":"pandoc-output-is-too-large","errorCode":null,"errorMessage":"pandoc output is too large","messagePattern":"pandoc output is too large","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"kernel/api/lute_clipboard_math.go","lineNumber":107,"sourceCode":"\t}\n\tmarkdown, converted, err := convertClipboardMathWithRunner(\"\", \"\", base64.StdEncoding.EncodeToString(input), runClipboardMathPandoc)\n\tif err != nil {\n\t\tlogging.LogWarnf(\"convert Office HTML clipboard math with pandoc failed: %s\", err)\n\t}\n\treturn markdown, converted\n}\n\nfunc convertClipboardMathWithRunner(mathML, office, wps string, runner clipboardMathPandocRunner) (markdown string, converted bool, err error) {\n\tfrom, input, ok := clipboardMathPandocInput(mathML, office, wps)\n\tif !ok {\n\t\treturn\n\t}\n\toutput, err := runner(from, \"json\", input)\n\tif err != nil {\n\t\treturn \"\", false, err\n\t}\n\tif len(output) > maxClipboardMathPandocOutput {\n\t\treturn \"\", false, fmt.Errorf(\"pandoc output is too large\")\n\t}\n\tmath, ok := parsePandocSingleMath(output)\n\tif !ok {\n\t\tif from != \"docx\" || !isSimplePandocMathDocument(output) {\n\t\t\treturn \"\", false, nil\n\t\t}\n\t\tmarkdownOutput, writeErr := runner(\"json\", \"markdown-raw_attribute\", output)\n\t\tif writeErr != nil {\n\t\t\treturn \"\", false, writeErr\n\t\t}\n\t\tif len(markdownOutput) > maxClipboardMathPandocOutput {\n\t\t\treturn \"\", false, fmt.Errorf(\"pandoc output is too large\")\n\t\t}\n\t\tmarkdown = strings.TrimSpace(strings.ReplaceAll(string(markdownOutput), \"<!-- -->\", \"\"))\n\t\treturn markdown, markdown != \"\", nil\n\t}\n\tif math.display {\n\t\treturn \"$$\\n\" + math.tex + \"\\n$$\", true, nil","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/api/lute_clipboard_math.go#L89-L125","documentation":"convertClipboardMathWithRunner runs the pandoc runner to convert clipboard math (e.g. from docx/latex sources) and enforces maxClipboardMathPandocOutput on the produced JSON. If pandoc's output exceeds that limit the conversion is aborted with 'pandoc output is too large' to protect the kernel from unbounded memory/CPU on pathological inputs.","triggerScenarios":"Pasting clipboard content whose single-math pandoc JSON serialization exceeds maxClipboardMathPandocOutput — huge embedded equations, documents with enormous OMML/Docx math, or a runner misconfigured to output the whole document instead of one math node.","commonSituations":"Pasting a very large Word formula object; WPS-produced docx with bloated math markup; a bug causing the runner to convert the entire document rather than the selected math.","solutions":["Reduce the size of the pasted math (split it into several smaller equations).","Verify the input passed to the runner is a single math snippet, not the full document; for docx the fallback isSimplePandocMathDocument path only handles simple docs.","Raise maxClipboardMathPandocOutput if legitimate equations are being rejected (trade-off with memory use).","Strip irrelevant formatting from the source before conversion (e.g. re-export the equation cleanly from Word/WPS)."],"exampleFix":"// before\noutput := convertEntireDocxToPandocJSON(clip) // too large\n\n// after\nmathXML := extractSingleOMML(clip) // just the equation\noutput, ok, err := convertClipboardMathWithRunner(runner, \"docx\", mathXML)","handlingStrategy":"fallback","validationCode":"const rough = input.length * 8; if (rough > maxClipboardMathPandocOutput) askUserToSplitEquation()","typeGuard":null,"tryCatchPattern":"try { math = await convertClipboardMath(src) }\ncatch (e) { if (e.message === \"pandoc output is too large\") { fallbackToPlainRender(); notify(\"Equation too large, rendered as-is\") } else throw e }","preventionTips":["Convert single math snippets, never whole documents","Split very large composite equations before pasting","Benchmark worst-case equation sizes against maxClipboardMathPandocOutput when changing limits"],"tags":["pandoc","clipboard","math","size-limit"],"backgroundTag":"file-size-limit-exceeded","analyzedSha":"9f775e8a12daef8255556097396f9b2739078892","analyzedAt":"2026-09-19T03:17:15.984Z","contentChangedAt":"2026-09-19T03:17:15.984Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}