siyuan-note/siyuan · error
encoded style entity is not attached to an attribute view…
Error message
encoded style entity is not attached to an attribute view rich text span
What it means
After parsing, a node's style attribute still contains a protected entity sentinel, but the node carrying it is not a plain text-mark span (type "text"). Sentinels are only allowed to survive inside style IALs of text spans; finding one attached to another node type means the protection round-trip left the encoded entity somewhere invalid.
Solutions
- Move the style attribute off the non-text node onto a proper text mark span (type "text") in the content
- Remove the sentinel/encoded entity from the offending node's style entirely and re-apply the style in the editor
- Regenerate the content through the SiYuan editor instead of hand-editing stored kramdown
- If produced by custom code, ensure style entity protection only applies to text-mark spans
Example fix
// before
<span data-type="code"{: style="color:#f00"x""}>code</span>
// after
<span data-type="text"{: style="color:#f00"}>code</span> Defensive patterns
Strategy: validation
Validate before calling
// ensure sentinel only in style of text marks
if strings.Contains(textContent, sentinel) { return errors.New("sentinel leaked into text") } Prevention
- Only attach style IALs to text-mark spans
- Never copy protected (sentinel-bearing) content between values
- Regenerate content through the editor after custom processing
- Test round-trips: protect -> parse -> restore must leave no sentinels
When it happens
Trigger: The restore walk in restoreValueTextRichTreeStyleEntities detects sentinel in node style via the styleProtected condition while node.IsTextMarkType("text") is false (e.g. the sentinel leaked into a code/math/inline-math or other mark type's style), at kernel/av/value.go:1957.
Common situations: Content where HTML entities in styles were hand-crafted into non-text marks; spliced kramdown moving IAL styles onto unsupported nodes; custom post-processing that re-parents styles.
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
- invalid encoded style entity in attribute view rich text…
- inconsistent attribute view rich text style entity sentinel
- unsupported attribute view rich text node
- attribute view rich text normalization did not converge
- attribute view rich text style entity sentinel was not…
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/0e0106648461944a.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/value.go:1957
styleReplacer := strings.NewReplacer(stylePairs...)
literalReplacer := strings.NewReplacer(literalPairs...)
textMarkCodeReplacer := strings.NewReplacer(textMarkCodePairs...)
textMarkInlineMathReplacer := strings.NewReplacer(textMarkInlineMathPairs...)
ast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {
if !entering {
return ast.WalkContinue
}
style := node.IALAttr("style")
styleProtected := strings.Contains(style, sentinel)
textProtected := ast.NodeTextMark == node.Type && strings.Contains(node.TextMarkTextContent, sentinel)
inlineMathProtected := ast.NodeTextMark == node.Type &&
strings.Contains(node.TextMarkInlineMathContent, sentinel)
tokens := string(node.Tokens)
tokensProtected := strings.Contains(tokens, sentinel)
if styleProtected {
if !node.IsTextMarkType("text") {
err = fmt.Errorf("encoded style entity is not attached to an attribute view rich text span")
return ast.WalkStop
}
if textProtected || inlineMathProtected || tokensProtected ||
!markValueTextRichStyleProtections(style, sentinel, tokenIndexes, restored) {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text span")
return ast.WalkStop
}
style = styleReplacer.Replace(style)
node.SetIALAttr("style", style)
if nil != node.Next && ast.NodeKramdownSpanIAL == node.Next.Type {
node.Next.Tokens = parse.IAL2Tokens(node.KramdownIAL)
}
return ast.WalkContinue
}
if textProtected || inlineMathProtected {
if !node.IsTextMarkType("code") && !node.IsTextMarkType("inline-math") {
err = fmt.Errorf("invalid encoded style entity in attribute view rich text mark [%s]", node.TextMarkType)
return ast.WalkStopView on GitHub (pinned to 9f775e8a12)