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

Trim trailing line to ensure empty toc is empty #60

Merged
merged 2 commits into from
Sep 21, 2021

Conversation

Krinkle
Copy link
Contributor

@Krinkle Krinkle commented Sep 20, 2021

Use case:

{%- if include.toc -%}
	{%- capture jekyll_toc -%}{%- include toc.html html=content -%}{%- endcapture -%}
	{%- if jekyll_toc != '' -%}
		<div class="toc-wrapper">
		<h4>Table of contents</h4>{{ jekyll_toc }}</div>
	{%- endif -%}
{%- endif -%}

It is also possible to store the toc.html layout file in the Git repository without trailing newline. However, when copying it into other projects this is often not preserved since trailing newline at EOF is a commonly enforced convention by various tooling, including Git itself, and in text editors when merely opening the file to e.g. copy/paste the latest version.

Krinkle added a commit to qunitjs/jekyll-theme-amethyst that referenced this pull request Sep 20, 2021
* No TOC on group index pages.
* No TOC if there are no headings.

This applies allejo/jekyll-toc#60 as hotfix.
@allejo allejo merged commit 3883e1b into allejo:master Sep 21, 2021
@allejo
Copy link
Owner

allejo commented Sep 21, 2021

Thank you for the PR! I've tagged a minor release of v1.2.0 since using whitespace control requires Jekyll 3.5+.

@Krinkle Krinkle deleted the patch-1 branch September 21, 2021 02:09
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.

2 participants