# Hyperref package not working with titlesec package when compiled with make4ht

The hyperref package seems to have conflict with titlesec package when compiled with make4ht. The following document is compiled with make4ht. The compiled html file doesn't contain table of contents.

\documentclass{article}
\usepackage{titlesec}
\titleformat{\section}[runin]{\normalfont\bfseries}{\thesection.}{3pt}{}
\usepackage{hyperref}
\begin{document}
\tableofcontents
\section{First}
\section{Second}
\section{Third}
\end{document}


How could this be dealt with? Note that there is no problem when titlesec package and the command titleformat is removed.

This issue is not related to hyperref, it is really the \titleformat what causes the issue, namely the runin option. It seems to redefine the \section in a way where tex4ht isn't able to insert the HTML tags for headers and they are not saved to the TOC. Also the third section is missing from the document completely.

I've found that the hang format works with tex4ht, so there is an easy fix: just redefine the runin (and display, which has the same issue as runin) format to hang:

\Preamble{xhmtl}
\begin{document}
\titlelabel{\thetitle.}
\makeatletter
\let\ttlh@runin\ttlh@hang
\let\ttlh@display\ttlh@hang
\makeatother
\EndPreamble


I've added the \titlelabel{\thetitle.} line to get the dots after section number, because it seems that this feature isn't supported by tex4ht configuration for \titleformat-

It seems to work now: