import { Fragment, VNode } from "preact" import { useState } from "preact/hooks" import { JSXInternal } from "preact/src/jsx" export function ExchangeXmlTos({ doc }: { doc: Document }) { const termsNode = doc.querySelector('[ids=terms-of-service]') if (!termsNode) { return
not found
} return {Array.from(termsNode.children).map(renderChild)} } function renderChild(child: Element): VNode { const children = Array.from(child.children) switch (child.nodeName) { case 'title': return
{child.textContent}
case '#text': return case 'paragraph': return

{child.textContent}

case 'section': { return {children.map(renderChild)} } case 'bullet_list': { return } case 'enumerated_list': { return
    {children.map(renderChild)}
} case 'list_item': { return
  • {children.map(renderChild)}
  • } case 'block_quote': { return
    {children.map(renderChild)}
    } default: return
    unknown tag {child.nodeName}
    } } function AnchorWithOpenState(props: JSXInternal.HTMLAttributes) { const [open, setOpen] = useState(false) function doClick(e: JSXInternal.TargetedMouseEvent) { setOpen(!open); e.stopPropagation(); e.preventDefault(); } return }