Skip to content

Commit

Permalink
Use the list-style-type property over hardcoding the ul parent
Browse files Browse the repository at this point in the history
  • Loading branch information
200sc committed Jun 19, 2023
1 parent 29431fc commit 9a84156
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions html.go
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ func renderNode(node *ParsedNode, stack *trackingDrawStack, drawzone floatgeom.R
consumed = renderNode(node.FirstChild, stack, drawzone, state)
drawzone.Min = drawzone.Min.Sub(floatgeom.Point2{padding, 0})
case "li":
switch node.Raw.Parent.Data {
case "ul":
switch node.Style["list-style-type"] {
case "disc", "":
textSize := 16.0
if size, ok := parseLength(node.Style["font-size"]); ok {
textSize = size
Expand All @@ -718,13 +718,15 @@ func renderNode(node *ParsedNode, stack *trackingDrawStack, drawzone floatgeom.R
childDrawZone.Min = childDrawZone.Min.Add(floatgeom.Point2{paddingL, paddingT})
childDrawZone.Min = childDrawZone.Min.Add(floatgeom.Point2{bulletRadius * 2, 0})

// todo: is this the background of ul or the background of the text content child?
// q: is this the background of ul or the background of the text content child? a: child
// TODO: this background does not extend down to the bottom of letters like 'g' and 'y'

drawBackground(node, stack, childDrawZone, textSize+textVBuffer, math.MaxFloat64)
if node.FirstChild != nil {
consumed = renderNode(node.FirstChild, stack, childDrawZone, state)
}
default:
panic("unhandled")
}
// TODO: thead
// TODO: tfoot
Expand Down
1 change: 1 addition & 0 deletions html_node.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ func ParseNode(node *html.Node, opts ...ParseNodeOption) *ParsedNode {
"font-size": {},
"font-weight": {},
"width": {},
"list-style-type": {},
}
pn.CalculateStyle(cfg.CSS)
INHERIT_LOOP:
Expand Down

0 comments on commit 9a84156

Please sign in to comment.