Skip to content
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

Compact option #42

Closed
abhinav opened this issue Sep 11, 2023 · 0 comments · Fixed by #43
Closed

Compact option #42

abhinav opened this issue Sep 11, 2023 · 0 comments · Fixed by #43

Comments

@abhinav
Copy link
Owner

abhinav commented Sep 11, 2023

From #40:


Since we are at it, I just realized that it will render empty list items when a "parent" header is not present. For example, ### h3 renders

<h1>Table of Contents</h1>
<ul>
<li>
<ul>
<li>
<ul>
<li>
<a href="#h3">h3</a></li>
</ul>
</li>
</ul>
</li>
</ul>
<h3 id="h3">h3</h3>

Would probably make more sense to render existing items only, as the browser will happily render these empty items like so:
image


Originally posted by @meblum in #40 (comment)

Makes sense to add a "Compact" option to get rid of nodes like these.

TBD: Should Compact be the default or opt-in?

abhinav added a commit that referenced this issue Sep 11, 2023
Adds a new 'Compact' option.
This option transforms the TOC,
collapsing away empty intermediate levels
when there's a difference of greater than one between levels.

Adds entries to the README and an option to the demo playground
for the new feature.

Testing:
Besides hand-written test cases, rapid-based property tests were added
to verify that the resulting TOC contains all headings.

Resolves #42
abhinav added a commit that referenced this issue Sep 11, 2023
Adds a new 'Compact' option.
This option transforms the TOC,
collapsing away empty intermediate levels
when there's a difference of greater than one between levels.

Adds entries to the README and an option to the demo playground
for the new feature.

Testing:
Besides hand-written test cases, rapid-based property tests were added
to verify that the resulting TOC contains all headings.

Resolves #42
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 a pull request may close this issue.

1 participant