llm browser fixes

This commit is contained in:
developer committed 2026-10-19 15:39:46 +00:00
1 parent a4dbb75195
commit f8526bfb4e
8 files changed
+33 -15

No files matched your search

+19 -7
View File
@@ -221,8 +221,11 @@ func (r *mdRenderer) element(b *strings.Builder, n *html.Node) {
case atom.Dl:
r.defList(b, n)
case atom.Button, atom.A, atom.Span, atom.Strong, atom.Em, atom.Code, atom.Small, atom.Label:
// phrasing content at block position: keep it as its own paragraph
if s := strings.TrimSpace(r.inline(n)); s != "" {
// phrasing content at block position (nav links, card wrappers):
// render with full inline semantics so anchors keep their href
var ib strings.Builder
r.inlineNode(&ib, n)
if s := strings.TrimSpace(ib.String()); s != "" {
b.WriteString(s + "\n\n")
}
default:
@@ -230,6 +233,19 @@ func (r *mdRenderer) element(b *strings.Builder, n *html.Node) {
}
}
// inlineNode renders one child node with inline semantics — the single
// dispatch point for list items and block-position phrasing elements, so
// anchors keep their href wherever they appear.
func (r *mdRenderer) inlineNode(b *strings.Builder, n *html.Node) {
if n.Type == html.TextNode {
b.WriteString(collapse(n.Data))
return
}
if n.Type == html.ElementNode {
r.inlineElement(b, n)
}
}
// list renders ul/ol items; nested lists indent under their item.
func (r *mdRenderer) list(b *strings.Builder, n *html.Node, indent string) {
ordered := n.DataAtom == atom.Ol
@@ -258,11 +274,7 @@ func (r *mdRenderer) list(b *strings.Builder, n *html.Node, indent string) {
nested = append(nested, c)
continue
}
if c.Type == html.TextNode {
text.WriteString(collapse(c.Data))
} else {
text.WriteString(r.inline(c))
}
r.inlineNode(&text, c)
}
if item := strings.TrimSpace(text.String()); item != "" {
b.WriteString(indent + marker + item + "\n")