renderFragment serialises a fragment-rooted html tree to a string. We use the html package's Render which always emits the document-style markup; for fragment input we strip the implicit ... wrapper that html.Parse adds.
(root *xhtml.Node)
| 469 | // for fragment input we strip the implicit <html><head></head><body>...</body></html> |
| 470 | // wrapper that html.Parse adds. |
| 471 | func renderFragment(root *xhtml.Node) string { |
| 472 | var buf bytes.Buffer |
| 473 | for child := root.FirstChild; child != nil; child = child.NextSibling { |
| 474 | _ = xhtml.Render(&buf, child) |
| 475 | } |
| 476 | return buf.String() |
| 477 | } |
| 478 | |
| 479 | // applyFeishuNativeStyles walks the tree (post-tag-pass) and ensures elements |
| 480 | // that have known Feishu mail-editor native inline styles get them autofilled. |