siyuan-note/siyuan · error
invalid attribute view rich text span style IAL
Error message
invalid attribute view rich text span style IAL
What it means
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.
Source
Thrown at kernel/av/value.go:1514
start := strings.Index(markdown[cursor:], marker)
if 0 > start {
builder.WriteString(markdown[cursor:])
break
}
start += cursor
builder.WriteString(markdown[cursor:start])
for literalRangeIndex < len(literalRanges) && literalRanges[literalRangeIndex].end <= start {
literalRangeIndex++
}
if literalRangeIndex < len(literalRanges) && literalRanges[literalRangeIndex].start <= start {
builder.WriteString(marker)
cursor = start + len(marker)
continue
}
ialStart := start + len("</span>")
valueStart, valueEnd, ialEnd, ok := valueTextRichSpanIALStyleBounds(markdown[ialStart:])
if !ok {
return "", nil, fmt.Errorf("invalid attribute view rich text span style IAL")
}
valueStart += ialStart
valueEnd += ialStart
ialEnd += ialStart
builder.WriteString(markdown[start:valueStart])
style, protected := protectValueTextRichStyleEntities(markdown[valueStart:valueEnd],
sentinel, len(protections))
builder.WriteString(style)
protections = append(protections, protected...)
builder.WriteString(markdown[valueEnd:ialEnd])
cursor = ialEnd
}
return builder.String(), protections, nil
}
func valueTextRichSpanIALStyleBounds(ial string) (valueStart, valueEnd, end int, ok bool) {
if !strings.HasPrefix(ial, "{: ") && !strings.HasPrefix(ial, "{:\t") &&
!strings.HasPrefix(ial, "{:\n") && !strings.HasPrefix(ial, "{:\r") {View on GitHub (pinned to 8641553a1f)
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
Example fix
// before
content = "<span style=\"color:red\">text</span>" // trailing IAL missing
// after
content = "<span style=\"color:red\">text</span>{: style=\"color:red\"}" Defensive patterns
Strategy: validation
Validate before calling
re := regexp.MustCompile(`</span>\{: style="[^"]*"\}`)
if strings.Contains(markdown, "</span>") && !re.MatchString(markdown) { /* fix or reject input */ } Try / catch
if err != nil && strings.Contains(err.Error(), "invalid attribute view rich text span style IAL") {
// rebuild the span content via the kernel's normalize path
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- unsupported attribute view rich text format [%s]
- encoded style entity is not attached to an attribute view ri
- invalid encoded style entity in attribute view rich text spa
- Invalid attribute view rich text style entity
- ErrRichTextSpecMismatch
AI-assisted analysis of siyuan-note/siyuan@8641553a1f (2026-09-11).
Data as JSON: /api/errors/d4db31cc92c21b12.
Report an issue: GitHub.