div内にヘッダーがある場合、目次が機能しない?

Does the table of contents not work when headers are inside a div? I am trying to make a table of contents with the headers centered but it seems impossible to do.

「いいね!」 1

I think this was mentioned previously, if I understand it right:

「いいね!」 5

So as far as I can tell basically there is no solution.

「いいね!」 3

It depends on what you try to achieve with your other HTML content.

I crosspost a potential workaround: TOC doesn't work when wrapped with HTML tags - #2 by Canapin

「いいね!」 2