siyuan-note/siyuan · error
pandoc output is too large
Error message
pandoc output is too large
What it means
convertClipboardMathWithRunner converts clipboard math (e.g. Word/WPS OMML) to Markdown via a pandoc runner. To avoid pathological memory/CPU blowups from oversized pandoc output, any JSON conversion output exceeding maxClipboardMathPandocOutput is rejected with this error instead of being parsed. It is a deliberate safety guard, not a pandoc failure.
Source
Thrown at kernel/api/lute_clipboard_math.go:107
}
markdown, converted, err := convertClipboardMathWithRunner("", "", base64.StdEncoding.EncodeToString(input), runClipboardMathPandoc)
if err != nil {
logging.LogWarnf("convert Office HTML clipboard math with pandoc failed: %s", err)
}
return markdown, converted
}
func convertClipboardMathWithRunner(mathML, office, wps string, runner clipboardMathPandocRunner) (markdown string, converted bool, err error) {
from, input, ok := clipboardMathPandocInput(mathML, office, wps)
if !ok {
return
}
output, err := runner(from, "json", input)
if err != nil {
return "", false, err
}
if len(output) > maxClipboardMathPandocOutput {
return "", false, fmt.Errorf("pandoc output is too large")
}
math, ok := parsePandocSingleMath(output)
if !ok {
if from != "docx" || !isSimplePandocMathDocument(output) {
return "", false, nil
}
markdownOutput, writeErr := runner("json", "markdown-raw_attribute", output)
if writeErr != nil {
return "", false, writeErr
}
if len(markdownOutput) > maxClipboardMathPandocOutput {
return "", false, fmt.Errorf("pandoc output is too large")
}
markdown = strings.TrimSpace(strings.ReplaceAll(string(markdownOutput), "<!-- -->", ""))
return markdown, markdown != "", nil
}
if math.display {
return "$$\n" + math.tex + "\n$$", true, nilView on GitHub (pinned to 8641553a1f)
Solutions
- Reduce the amount of clipboard content converted at once - convert a single formula or equation region, not the whole document.
- Strip non-math content from the HTML/clipboard payload before calling the conversion.
- Raise maxClipboardMathPandocOutput if legitimate large conversions must be supported, accepting the memory trade-off.
- Treat the error as 'skip math conversion' and fall back to plain paste handling.
Example fix
// before: converting the whole clipboard HTML
math, ok, err := convertClipboardMath(clipboardHTML)
// after: cap input size before conversion
if len(clipboardHTML) > maxClipboardMathInputSize {
clipboardHTML = truncateToMathRegion(clipboardHTML)
}
math, ok, err := convertClipboardMath(clipboardHTML) Defensive patterns
Strategy: try-catch
Validate before calling
if (new Blob([clipboardHTML]).size > MAX_INPUT_BYTES) {
// trim to math region or warn user before converting
} Type guard
function isReasonablePandocOutput(out: Uint8Array, limit: number): boolean {
return out.byteLength > 0 && out.byteLength <= limit;
} Try / catch
try {
const md = await convertClipboardMath(html);
} catch (e) {
if (String(e.message).includes("too large")) {
pasteRaw(html); // graceful fallback
} else { throw e; }
} Prevention
- Convert only the selected formula, not entire documents.
- Pre-trim clipboard HTML to the math region before calling the API.
- Log output sizes in dev to calibrate your expectations of the limit.
- Always code a raw-paste fallback path for conversion errors.
When it happens
Trigger: Calling convertClipboardMath or convertOfficeHTMLClipboardMath with clipboard content whose pandoc JSON conversion output exceeds maxClipboardMathPandocOutput bytes; the runner itself succeeds but the size check at lute_clipboard_math.go:107 fails.
Common situations: Pasting very large Word/WPS documents full of equations into the editor; a clipboard event carrying an entire document rather than a single formula; pathological content that makes pandoc's JSON AST representation balloon well beyond the original text size.
Understand the failure class
Background: payload too large / request exceeds maximum size: why libraries cap bytes and how to fix oversize payloads — this error's family across 50 libraries.
Related errors
- Agent capability name and description are required
- Please configure [Settings - Export - Pandoc - Path to Pando
- not found executable pandoc
- BASE64_IMAGE_SIZE_LIMIT
- invalid custom emoji image
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/e19040f52eed6caa.
Report an issue: GitHub.