{"record":{"id":"0e0106648461944a","repo":"siyuan-note/siyuan","slug":"encoded-style-entity-is-not-attached-to-an-attribu","errorCode":null,"errorMessage":"encoded style entity is not attached to an attribute view rich text span","messagePattern":"encoded style entity is not attached to an attribute view rich text span","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":1957,"sourceCode":"\tstyleReplacer := strings.NewReplacer(stylePairs...)\n\tliteralReplacer := strings.NewReplacer(literalPairs...)\n\ttextMarkCodeReplacer := strings.NewReplacer(textMarkCodePairs...)\n\ttextMarkInlineMathReplacer := strings.NewReplacer(textMarkInlineMathPairs...)\n\n\tast.Walk(tree.Root, func(node *ast.Node, entering bool) ast.WalkStatus {\n\t\tif !entering {\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tstyle := node.IALAttr(\"style\")\n\t\tstyleProtected := strings.Contains(style, sentinel)\n\t\ttextProtected := ast.NodeTextMark == node.Type && strings.Contains(node.TextMarkTextContent, sentinel)\n\t\tinlineMathProtected := ast.NodeTextMark == node.Type &&\n\t\t\tstrings.Contains(node.TextMarkInlineMathContent, sentinel)\n\t\ttokens := string(node.Tokens)\n\t\ttokensProtected := strings.Contains(tokens, sentinel)\n\t\tif styleProtected {\n\t\t\tif !node.IsTextMarkType(\"text\") {\n\t\t\t\terr = fmt.Errorf(\"encoded style entity is not attached to an attribute view rich text span\")\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tif textProtected || inlineMathProtected || tokensProtected ||\n\t\t\t\t!markValueTextRichStyleProtections(style, sentinel, tokenIndexes, restored) {\n\t\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text span\")\n\t\t\t\treturn ast.WalkStop\n\t\t\t}\n\t\t\tstyle = styleReplacer.Replace(style)\n\t\t\tnode.SetIALAttr(\"style\", style)\n\t\t\tif nil != node.Next && ast.NodeKramdownSpanIAL == node.Next.Type {\n\t\t\t\tnode.Next.Tokens = parse.IAL2Tokens(node.KramdownIAL)\n\t\t\t}\n\t\t\treturn ast.WalkContinue\n\t\t}\n\t\tif textProtected || inlineMathProtected {\n\t\t\tif !node.IsTextMarkType(\"code\") && !node.IsTextMarkType(\"inline-math\") {\n\t\t\t\terr = fmt.Errorf(\"invalid encoded style entity in attribute view rich text mark [%s]\", node.TextMarkType)\n\t\t\t\treturn ast.WalkStop","sourceCodeStart":1939,"sourceCodeEnd":1975,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/9f775e8a12daef8255556097396f9b2739078892/kernel/av/value.go#L1939-L1975","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n<span data-type=\"code\"{: style=\"color:#f00&quot;x&quot;\"}>code</span>\n// after\n<span data-type=\"text\"{: style=\"color:#f00\"}>code</span>","handlingStrategy":"validation","validationCode":"// ensure sentinel only in style of text marks\nif strings.Contains(textContent, sentinel) { return errors.New(\"sentinel leaked into text\") }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["attribute-view","rich-text","entity-protection","ast-validation"],"backgroundTag":"internal-invariant-violation","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"}