siyuan-note/siyuan · error

attribute view rich text normalization did not converge

Error message

attribute view rich text normalization did not converge

What it means

Rich text normalization renders the parsed tree to Kramdown, re-parses, and repeats, expecting the round-trip to reach a fixed point. If after 4 iterations the content still keeps changing (or the first stable comparison never matches), the normalizer gives up with this error. It indicates content whose Kramdown representation is not stable under parse/render, usually due to unusual or nested constructs.

Solutions

  1. Simplify the content: remove nested/redundant span constructs and unusual entity escapes, then retry
  2. Regenerate the content via the editor so it is emitted in Lute's canonical form
  3. Minimize the failing snippet and report it upstream (Lute/SiYuan) as a normalization convergence bug
  4. If the value is from an import, try importing without the offending constructs and apply them via the UI

Example fix

// before: content oscillating between forms
<span data-type="text" style="..."><span data-type="text">a</span></span>
// after: flattened single span
<span data-type="text" style="...">a</span>
Defensive patterns

Strategy: try-catch

Validate before calling

// pre-check for suspicious nesting depth in generated rich text
if ((content.match(/<span/g) || []).length > 20) {
  console.warn("deeply nested spans may not normalize");
}

Try / catch

try { NormalizeValueTextRich(rich) } catch (e) { if (String(e).includes("did not converge")) { rich = simplifyAndFlatten(rich); retryOnce(); } }

Prevention

When it happens

Trigger: Calling NormalizeValueTextRich / NormalizeRichContent with content that alternates representation on each parse/render cycle, e.g. entities that keep re-escaping, nested span/IAL constructs that re-nest each pass, or pathological style/entity combinations.

Common situations: Machine-generated rich text with deeply nested or redundant spans; content imported from another Markdown dialect with constructs Lute re-writes each pass; a Lute engine bug on new syntax.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19). Data as JSON: /api/errors/8579d8f51078ab8f. Report an issue: GitHub.

Appendix: source

Thrown at kernel/av/value.go:2139

	for iteration := 0; iteration < 4; iteration++ {
		if err = normalizeValueTextRichTreeStyles(normalizedTree); nil != err {
			return "", nil, err
		}
		luteEngine := newValueTextRichLute()
		blockDOM := luteEngine.Tree2BlockDOM(normalizedTree, luteEngine.RenderOptions, luteEngine.ParseOptions)
		content = valueTextRichBlockDOM2Kramdown(luteEngine, blockDOM)
		if 0 < iteration && previous == content {
			return content, normalizedTree, nil
		}
		previous = content
		candidate := &ValueTextRich{
			Spec: ValueTextRichSpec, Format: ValueTextRichFormatKramdown, Content: content,
		}
		if _, normalizedTree, err = parseValueTextRichWithImages(candidate, images); nil != err {
			return "", nil, err
		}
	}
	return "", nil, fmt.Errorf("attribute view rich text normalization did not converge")
}

// NormalizeRichContent 校验富文本载荷,并根据富文本源刷新纯文本投影。
func (value *ValueText) NormalizeRichContent() (err error) {
	if !value.IsRich() {
		return
	}
	tree, err := NormalizeValueTextRich(value.Rich)
	if nil != err {
		return err
	}
	value.Content = valueTextRichPlainContent(tree)
	return
}

func valueTextRichPlainContent(tree *parse.Tree) string {
	if nil == tree || nil == tree.Root {
		return ""

View on GitHub (pinned to 9f775e8a12)