Skip to content

[TableOfContents] Add a label option #1074

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

DanielEScherzer
Copy link
Contributor

By default no label is shown, but if one is set it is added as a <strong> before the first item in the table of contents.

By default no label is shown, but if one is set it is added as a `<strong>`
before the first item in the table of contents.
@DanielEScherzer
Copy link
Contributor Author

The failing check continuous-integration/styleci/pr says

We were unable to access the repo or commit to analyze it.

So I don't think that is something that I can fix

@froschdesign
Copy link
Contributor

…it is added as a <strong> before the first item in the table of contents.

Which produces invalid HTML: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ul#technical_summary

@colinodell
Copy link
Member

Have you considered using the 'position' => 'placeholder' option instead? It allows much more flexibility, such as providing a heading (which could be made linkable thanks to the Heading Permalinks extension):

## Table of Contents

[TOC]

@DanielEScherzer
Copy link
Contributor Author

Have you considered using the 'position' => 'placeholder' option instead? It allows much more flexibility, such as providing a heading (which could be made linkable thanks to the Heading Permalinks extension):

## Table of Contents

[TOC]

I wanted the heading to be more clearly part of the TOC itself, so that is why I didn't have a placeholder.
You can see how I'm using a label at https://scherzer.dev/Blog/20250429-attributes-on-constants in the sidebar

…it is added as a \<strong\> before the first item in the table of contents.

Which produces invalid HTML: https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/ul#technical_summary

Good point - what would you think of having a wrapping div when a label is requested?

<div class="table-of-contents-wrapper">
<strong>Table of Contents</strong>
<ul class="table-of-contents">
<li>...
</ul>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants