Table of contents strips `code blocks` from header titles

I’ve noticed that if I include code blocks in my headings, the contents won’t be in a codeblock in the table of contents. That’s not the behavior I want. I’m not sure how it should be changed, though.

Firstly, should the title property become the marked up one, with the functionality without tags being moved to title | striptags, or should a new property be introduced?

Secondly, there’s the question of whether said property should include HTML or Markdown.

I briefly looked around and found the relevant code, but I’m pretty sure implementing a variant of get_text that handles inline code blocks is a bad idea.

Thoughts?

I think it makes sense to strip HTML for the toc, otherwise you can end up with toc having random html in it.

The current behaviour makes sense to me so I wouldn’t change it or add options to it I think since it would become pretty unwieldy.

What about formatting marks?

I believe elements that can be represented with span elements should be retained, for example, inline-code and italics as they are also allowed within block elements of HTML.

Perhaps adding just support for the span elements would be enough and would preserve formatting without breaking any layouts.