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 scanning kramdown markdown for span-level style IALs (protectValueTextRichStyleEntities / the span-style scanning pass), a closing </span> was found but the following style attribute bounds could not be located — the IAL after the closing tag is missing or malformed. The scanner requires the exact pattern of a span whose style value sits between recognizable bounds so it can protect entity-encoding; anything else is rejected as invalid.
Solutions
- Fix the markup so each </span> is directly followed by a well-formed kramdown IAL like {: style="..."} on the same construct
- Remove stray characters between the closing tag and the IAL, or delete the orphaned </span> entirely
- Re-generate the content from the SiYuan editor (edit the cell and re-apply formatting) rather than editing stored kramdown by hand
- Validate with lute: parse the content in isolation (Md2BlockDOMTree) to confirm the span/IAL structure is intact
Example fix
// before
<span style="color:#f00">text</span> color: red
// after
<span style="color:#f00">text</span>{: style="color:#f00"} Defensive patterns
Strategy: validation
Validate before calling
// every closing span must be immediately followed by {: style="..."}
re := regexp.MustCompile(`</span>[^{]`)
if re.MatchString(content) { return errors.New("orphaned </span> without IAL") } Prevention
- Never edit stored kramdown by hand; regenerate via the editor
- Keep span tags and their IALs contiguous with no interleaved text
- Validate content with lute parse before persisting programmatically
- Escape stray literal </span> text in content
When it happens
Trigger: Rich text content containing </span> followed by something other than a well-formed IAL style attribute (e.g. "</span>{: ..." missing closing brace, missing style= key, stray text after the closing tag before the IAL), processed through the span style protection pass on kernel/av/value.go around line 1522.
Common situations: Hand-edited or machine-spliced kramdown where the span markup and IAL got separated; truncated content from a failed write; content copied from another kramdown dialect with slightly different IAL syntax.
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
- attribute view rich text normalization did not converge
- attribute view rich text style entity sentinel was not…
- attribute view rich text style entity was not restored
- attribute view rich text tree is missing
AI-assisted analysis of siyuan-note/siyuan@9f775e8a12 (2026-09-19).
Data as JSON: /api/errors/d4db31cc92c21b12.
Report an issue: GitHub.
Appendix: source
Thrown at kernel/av/value.go:1522
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 9f775e8a12)