Skip to content

Commit 783d432

Browse files
authored
Merge pull request #1643 from cogentcore/lists
lists: content -- major fix to nested lists
2 parents e2a8f95 + f577cf1 commit 783d432

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

htmlcore/handler.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,13 +191,16 @@ func handleElement(ctx *Context) {
191191

192192
if hasPChild { // handle potential additional <p> blocks that should be indented
193193
cnode := ctx.Node
194+
orignode := cnode
194195
// ctx.BlockParent = text.Parent.(core.Widget)
196+
got := false
195197
for cnode.NextSibling != nil {
196198
cnode = cnode.NextSibling
197-
ctx.Node = cnode
198199
if cnode.Data != "p" {
199-
continue
200+
break
200201
}
202+
ctx.Node = cnode
203+
got = true
201204
txt, psub := handleTextExclude(ctx, "ol", "ul")
202205
txt.SetText(txt.Text)
203206
ctx.handleWidget(cnode, txt)
@@ -208,6 +211,9 @@ func handleElement(ctx *Context) {
208211
break
209212
}
210213
}
214+
if !got && cnode != nil && cnode != orignode {
215+
readHTMLNode(ctx, ctx.Parent(), cnode)
216+
}
211217
}
212218
if sublist != nil {
213219
readHTMLNode(ctx, ctx.Parent(), sublist)
@@ -403,7 +409,8 @@ func handleTextExclude(ctx *Context, excludeSubs ...string) (*core.Text, *html.N
403409
return core.NewText(), excl
404410
}
405411
tx := New[core.Text](ctx).SetText(et)
406-
if strings.Contains(et, "\n") && !strings.Contains(et, "math display") {
412+
tag := ctx.Node.Data
413+
if tag != "li" && strings.Contains(et, "\n") && !strings.Contains(et, `<span class="math display">`) {
407414
tx.Styler(func(s *styles.Style) {
408415
s.Text.WhiteSpace = text.WhiteSpacePreWrap
409416
})

yaegicore/coresymbols/cogentcore_org-core-core.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)