# Table of contents strips \`code blocks\` from header titles

**URL:** <https://zola.discourse.group/t/table-of-contents-strips-code-blocks-from-header-titles/982>\
**Category:** Feature requests\
**Created:** [July 12, 2021, 3:22pm UTC](https://zola.discourse.group/t/table-of-contents-strips-code-blocks-from-header-titles/982 "2021-07-12T15:22:19Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![NieDzejkob](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/niedzejkob/32/519_2.png) [@NieDzejkob](https://zola.discourse.group/u/NieDzejkob)\
**Post date:** [July 12, 2021, 3:22pm UTC](https://zola.discourse.group/t/table-of-contents-strips-code-blocks-from-header-titles/982/1 "2021-07-12T15:22:19Z")

</div>

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](https://github.com/getzola/zola/blob/312ffcb04c06c5f157b9fd2b944b858703238592/components/rendering/src/markdown.rs#L402), but I’m pretty sure implementing a variant of `get_text` that handles inline code blocks is a bad idea.

Thoughts?

---

<div class="post-metadata">

**Author:** ![keats](https://avatars.discourse-cdn.com/v4/letter/k/34f0e0/32.png) [@keats](https://zola.discourse.group/u/keats)\
**Post date:** [July 13, 2021, 5:50pm UTC](https://zola.discourse.group/t/table-of-contents-strips-code-blocks-from-header-titles/982/2 "2021-07-13T17:50:28Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![xypnox](https://yyz2.discourse-cdn.com/free1/user_avatar/zola.discourse.group/xypnox/32/325_2.png) [@xypnox](https://zola.discourse.group/u/xypnox)\
**Post date:** [July 13, 2021, 6:46pm UTC](https://zola.discourse.group/t/table-of-contents-strips-code-blocks-from-header-titles/982/3 "2021-07-13T18:46:09Z")

</div>

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.
