{"record":{"id":"d4db31cc92c21b12","repo":"siyuan-note/siyuan","slug":"invalid-attribute-view-rich-text-span-style-ial","errorCode":null,"errorMessage":"invalid attribute view rich text span style IAL","messagePattern":"invalid attribute view rich text span style IAL","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"kernel/av/value.go","lineNumber":1514,"sourceCode":"\t\tstart := strings.Index(markdown[cursor:], marker)\n\t\tif 0 > start {\n\t\t\tbuilder.WriteString(markdown[cursor:])\n\t\t\tbreak\n\t\t}\n\t\tstart += cursor\n\t\tbuilder.WriteString(markdown[cursor:start])\n\t\tfor literalRangeIndex < len(literalRanges) && literalRanges[literalRangeIndex].end <= start {\n\t\t\tliteralRangeIndex++\n\t\t}\n\t\tif literalRangeIndex < len(literalRanges) && literalRanges[literalRangeIndex].start <= start {\n\t\t\tbuilder.WriteString(marker)\n\t\t\tcursor = start + len(marker)\n\t\t\tcontinue\n\t\t}\n\t\tialStart := start + len(\"</span>\")\n\t\tvalueStart, valueEnd, ialEnd, ok := valueTextRichSpanIALStyleBounds(markdown[ialStart:])\n\t\tif !ok {\n\t\t\treturn \"\", nil, fmt.Errorf(\"invalid attribute view rich text span style IAL\")\n\t\t}\n\t\tvalueStart += ialStart\n\t\tvalueEnd += ialStart\n\t\tialEnd += ialStart\n\t\tbuilder.WriteString(markdown[start:valueStart])\n\t\tstyle, protected := protectValueTextRichStyleEntities(markdown[valueStart:valueEnd],\n\t\t\tsentinel, len(protections))\n\t\tbuilder.WriteString(style)\n\t\tprotections = append(protections, protected...)\n\t\tbuilder.WriteString(markdown[valueEnd:ialEnd])\n\t\tcursor = ialEnd\n\t}\n\treturn builder.String(), protections, nil\n}\n\nfunc valueTextRichSpanIALStyleBounds(ial string) (valueStart, valueEnd, end int, ok bool) {\n\tif !strings.HasPrefix(ial, \"{: \") && !strings.HasPrefix(ial, \"{:\\t\") &&\n\t\t!strings.HasPrefix(ial, \"{:\\n\") && !strings.HasPrefix(ial, \"{:\\r\") {","sourceCodeStart":1496,"sourceCodeEnd":1532,"githubUrl":"https://github.com/siyuan-note/siyuan/blob/8641553a1f07374001902d3ce773285db1292b2d/kernel/av/value.go#L1496-L1532","documentation":"When re-serializing rich text, the code scans for `</span>` followed by a style IAL and computes the style value/IAL bounds with valueTextRichSpanIALStyleBounds. If the text after `</span>` is not a well-formed style IAL ({: style=\"...\"}), the bounds function returns ok=false and the serializer aborts with this error, since it cannot safely split and rewrite the span style.","triggerScenarios":"Kramdown source containing a closing `</span>` not followed by a valid IAL block — e.g. truncated IALs, missing closing braces/quotes, nested or duplicated spans from manual editing, or the IAL mangled by earlier text processing. Raised in the span-IAL rewrite path around kernel/av/value.go:1514.","commonSituations":"Hand-edited kramdown where the {: style=\"...\"} tail was deleted or broken; string manipulation/regex by plugins or scripts corrupting span tails; copy-paste that split an IAL across lines; older exports with a different span serialization.","solutions":["Repair the span markup so every `</span>` is immediately followed by a complete IAL like {: style=\"color:red\"}","Delete the malformed span entirely and re-create the styled text in the SiYuan editor","Check for and undo external string processing (scripts/plugins) that truncated or reflowed the IAL","Normalize the content via NormalizeValueTextRich / re-save through the kernel to regenerate well-formed span IALs"],"exampleFix":"// before\ncontent = \"<span style=\\\"color:red\\\">text</span>\" // trailing IAL missing\n// after\ncontent = \"<span style=\\\"color:red\\\">text</span>{: style=\\\"color:red\\\"}\"","handlingStrategy":"validation","validationCode":"re := regexp.MustCompile(`</span>\\{: style=\"[^\"]*\"\\}`)\nif strings.Contains(markdown, \"</span>\") && !re.MatchString(markdown) { /* fix or reject input */ }","typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"invalid attribute view rich text span style IAL\") {\n    // rebuild the span content via the kernel's normalize path\n}","preventionTips":["Never post-process rich-text kramdown with string/regex edits","Keep each span and its trailing IAL on one unbroken unit","Regenerate styled text through the editor instead of patching serialized output"],"tags":["attribute-view","rich-text","ial","kramdown"],"backgroundTag":"invalid-argument-format","analyzedSha":"8641553a1f07374001902d3ce773285db1292b2d","analyzedAt":"2026-09-11T16:08:28.414Z","contentChangedAt":"2026-09-11T16:08:28.414Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}