\startxmlsetups html
  \xmlsetsetup{#1}{{html|head}}{html:flush}
  \xmlsetsetup{#1}{{html head script}}{html:script:context}
  \xmlsetsetup{#1}{{html body}}{html:body}
  \xmlsetsetup{#1}{p}{html:p}
\stopxmlsetups

\startxmlsetups html:flush
  \xmlflush{#1}
\stopxmlsetups

\startluacode
function xml.functions.parseScript(s)
  local mimetype = s and s.at and s.at.type
  if mimetype and mimetype == "text/vnd.context" then
    lxml.context(s)
  end
end
function xml.functions.flushBody(b)
  local xmlsetups = b and b.at and b.at["data-xmlsetups"]
  if xmlsetups then
    lxml.tobuffer(b, ".", "body")
    context("\\typebuffer[body]")
    context.xmlprocessbuffer("body", "body", xmlsetups)
  else
    lxml.flush(b)
  end
end
\stopluacode

\startxmlsetups html:script:context
  \xmlfunction{#1}{parseScript}
\stopxmlsetups

\startxmlsetups html:body
  \starttext
    \xmlfunction{#1}{flushBody}
  \stoptext
\stopxmlsetups

\startxmlsetups html:p
  \dontleavehmode\xmlflush{#1}\par
\stopxmlsetups

\xmlregistersetup{html}
