arXiv:2609.06993cs.SESep 2026

Manuscript Offprint

arXiv:2609.06993

LatentMD: Benchmarking Markdown Boundary Failures in LLM-Generated Text

Sungjune Lee, Myungjoo Kang

Abstract

Large language models (LLMs) increasingly generate Markdown that is consumed by renderers, agents, code extractors, and structured downstream pipelines. Yet existing evaluations often conflate content quality with format adherence, leaving Markdown boundary failures under-measured. We introduce LatentMD, a benchmark and evaluation protocol for diagnosing CommonMark-level fence-boundary failures in LLM-generated Markdown. LatentMD separates content correctness from boundary correctness, enabling detection of outputs that are content-correct but boundary-broken. The benchmark contains 4,179 prompts and a CLI for scoring arbitrary model outputs. Across 9 LLMs and roughly 37,600 generations, we find that Markdown boundary failures are widespread: 38.0% of valid main-grid outputs are content-correct but boundary-broken, with substantial boundary breakage under unspecified prompts and in a small human-authored validation set. Ablations show that failures are driven primarily by same-family symmetric-delimiter collisions rather than nesting alone, are only partially mitigated by prompt hints, and generalize to Python triple-quote docstrings while JSON remains robust as an asymmetric-delimiter control. LatentMD provides a reproducible diagnostic target for parser-sensitive LLM evaluation.

1 Introduction

LLM Markdown output is increasingly read by automated tools, not just human eyes — chat UIs render it on screen, agentic systems parse it to decide actions, and search-and-extraction systems pull code blocks out of it for reuse [20]. These tools rely on the implicit assumption that the output's structure is correct; when the structure breaks, the tools break with it.

This breaks regularly in the wild. A user asks a chat model to write a Markdown tutorial about Python generators with two code examples; the model wraps its reply in a fenced block tagged markdown and embeds the two Python examples as inner fenced blocks. In many chat UIs and developer tools, this output visibly breaks: the inner fences close the outer wrapper at the first length match, and the trailing content leaks outside the intended block as raw text or stripped fence characters. In other cases the breakage is invisible at render time but still corrupts any tool that reads the document's spec-level structure.

This is not a contrived test case: the same fence-boundary failure has been filed across major LLM and developer tools, including OpenAI ChatKit, Google Gemini CLI, Microsoft VS Code, and open-source agentic projects [19, 11, 16, 2, 6, 17]. These incidents show that nested-fence breakage is a recurring deployment failure rather than a benchmark artefact.

*Code and scoring tool: https://anonymous.4open.science/r/LatentMD-code-B51D.

† Corresponding author.

Preprint.

Yet existing LLM-output benchmarks do not measure this failure. They score content correctness and surface format adherence [24, 5, 8, 25, 14], but none isolate whether the model can correctly track nested fence boundaries. A generation that is content-correct but boundary-broken would therefore be scored as passing by these benchmarks. The same output would still corrupt any spec-strict downstream parser or renderer. We close this gap with LatentMD, a 4,179-prompt rule-based benchmark that adds an explicit Boundary axis orthogonal to Content. This isolates a content-correct but boundary-broken failure mode, the latent failure. It supports paired causal and trend claims that aggregate-only benchmarks cannot.

Contributions. We make the following contributions. (a) Benchmark. We introduce LatentMD, the first systematic benchmark of LLM Markdown fence-boundary failures, comprising 4,179 prompts that systematically vary outer wrapping, inner nesting, and delimiter properties. (b) Diagnostic methodology. We define an error-type taxonomy (premature closure, unclosed fence, latent delimiter collision) and a four-cell decomposition that separates content correctness from CommonMark-level boundary correctness, surfacing latent failures missed by content/format-only evaluations. (c) Empirical study. Across 9 LLMs we show that Markdown boundary failures are widespread, driven primarily by same-family symmetric-delimiter collision, only partially mitigated by prompting, and echoed in Python but not JSON. (d) Reproducible artifact. We release prompts, generation scripts, and a stand-alone scoring tool for applying LatentMD to arbitrary model outputs.