Richard, looking at the current .lyx header i find a little bit disturbing those \html_latex_start "<span class='latex'>" and so on.
what about enclose all xhtml header stuff into something like xhtml().writeFile(os) and dump it only in non default case as we do with pdfoptions/spacing.writeFile? pavel