pax_global_header00006660000000000000000000000064140500665610014515gustar00rootroot0000000000000052 comment=22b07a30847359930d16c4d007c2e2b73bb22d9e jekyll-toc-0.17.1/000077500000000000000000000000001405006656100136605ustar00rootroot00000000000000jekyll-toc-0.17.1/.github/000077500000000000000000000000001405006656100152205ustar00rootroot00000000000000jekyll-toc-0.17.1/.github/dependabot.yml000066400000000000000000000011261405006656100200500ustar00rootroot00000000000000# To get started with Dependabot version updates, you'll need to specify which # package ecosystems to update and where the package manifests are located. # Please see the documentation for all configuration options: # https://help.github.com/github/administering-a-repository/configuration-options-for-dependency-updates version: 2 updates: - package-ecosystem: "bundler" directory: "/" schedule: interval: "weekly" reviewers: - toshimaru - package-ecosystem: "github-actions" directory: "/" schedule: interval: "weekly" reviewers: - toshimaru jekyll-toc-0.17.1/.github/workflows/000077500000000000000000000000001405006656100172555ustar00rootroot00000000000000jekyll-toc-0.17.1/.github/workflows/ci.yml000066400000000000000000000012721405006656100203750ustar00rootroot00000000000000name: CI on: [push, pull_request] jobs: build: strategy: matrix: ruby: [2.5, 2.6, 2.7, 3.0] gemfile: - gemfiles/jekyll_3.9.gemfile - gemfiles/jekyll_4.0.gemfile - gemfiles/jekyll_4.1.gemfile - gemfiles/jekyll_4.2.gemfile env: BUNDLE_GEMFILE: ${{ matrix.gemfile }} runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install run: | gem install bundler bundle install --jobs 4 --retry 3 - name: Run Test run: bundle exec rake jekyll-toc-0.17.1/.github/workflows/coverage.yml000066400000000000000000000011561405006656100215760ustar00rootroot00000000000000name: Coverage on: [push, pull_request] jobs: build: strategy: matrix: ruby: [3.0] runs-on: ubuntu-latest name: coverage steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install run: bundle install --jobs 4 --retry 3 - uses: paambaati/codeclimate-action@v2.7.5 env: CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07 with: coverageCommand: bundle exec rake jekyll-toc-0.17.1/.github/workflows/rubocop.yml000066400000000000000000000007161405006656100214550ustar00rootroot00000000000000name: RuboCop on: [push, pull_request] jobs: build: strategy: matrix: ruby: [3.0] runs-on: ubuntu-latest name: rubocop steps: - uses: actions/checkout@v2 - name: Set up Ruby ${{ matrix.ruby }} uses: ruby/setup-ruby@v1 with: ruby-version: ${{ matrix.ruby }} - name: bundle install run: bundle install --jobs 4 --retry 3 - name: Run RuboCop run: bundle exec rubocop jekyll-toc-0.17.1/.gitignore000066400000000000000000000000671405006656100156530ustar00rootroot00000000000000*.gem /Gemfile.lock /.bundle/ /coverage *.gemfile.lock jekyll-toc-0.17.1/.rubocop.yml000066400000000000000000000013201405006656100161260ustar00rootroot00000000000000AllCops: TargetRubyVersion: 2.5 NewCops: enable Exclude: - "*.gemspec" - "gemfiles/*" - "vendor/**/*" - Rakefile - Gemfile require: - rubocop-performance - rubocop-minitest Metrics/MethodLength: Enabled: false Metrics/AbcSize: Enabled: false Metrics/ClassLength: Enabled: false Naming/FileName: Enabled: false Layout/LineLength: Enabled: false Layout/SpaceAroundMethodCallOperator: Enabled: true Lint/RaiseException: Enabled: true Lint/StructNewOverride: Enabled: true Style/WordArray: Enabled: false Style/HashEachMethods: Enabled: true Style/HashTransformKeys: Enabled: true Style/HashTransformValues: Enabled: true Style/ExponentialNotation: Enabled: true jekyll-toc-0.17.1/Appraisals000066400000000000000000000002771405006656100157100ustar00rootroot00000000000000# frozen_string_literal: true SUPPORTED_VERSIONS = %w[3.8 3.9 4.0 4.1 4.2].freeze SUPPORTED_VERSIONS.each do |version| appraise "jekyll-#{version}" do gem 'jekyll', version end end jekyll-toc-0.17.1/CHANGELOG.md000066400000000000000000000001431405006656100154670ustar00rootroot00000000000000Changelog is maintained under [Github Releases](https://github.com/toshimaru/jekyll-toc/releases). jekyll-toc-0.17.1/Gemfile000066400000000000000000000003441405006656100151540ustar00rootroot00000000000000source 'https://rubygems.org' gemspec gem 'appraisal' gem 'minitest-reporters' gem 'minitest' gem 'pry' gem 'rake' gem 'rubocop-minitest' gem 'rubocop-performance' gem 'rubocop-rake' gem 'rubocop' gem 'simplecov', '~> 0.17.1' jekyll-toc-0.17.1/LICENSE.md000066400000000000000000000020641405006656100152660ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) 2020 Toshimaru Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jekyll-toc-0.17.1/README.md000066400000000000000000000177411405006656100151510ustar00rootroot00000000000000# jekyll-toc ![CI](https://github.com/toshimaru/jekyll-toc/workflows/CI/badge.svg) [![Gem Version](https://badge.fury.io/rb/jekyll-toc.svg)](https://badge.fury.io/rb/jekyll-toc) [![Code Climate](https://codeclimate.com/github/toshimaru/jekyll-toc/badges/gpa.svg)](https://codeclimate.com/github/toshimaru/jekyll-toc) [![Test Coverage](https://api.codeclimate.com/v1/badges/cd56b207f327603662a1/test_coverage)](https://codeclimate.com/github/toshimaru/jekyll-toc/test_coverage) ## Table of Contents - [Installation](#installation) - [Usage](#usage) - [Basic Usage](#basic-usage) - [Advanced Usage](#advanced-usage) - [Generated HTML](#generated-html) - [Customization](#customization) - [Default Configuration](#default-configuration) - [TOC levels](#toc-levels) - [Enable TOC by default](#enable-toc-by-default) - [Skip TOC](#skip-toc) - [Skip TOC Sectionally](#skip-toc-sectionally) - [CSS Styling](#css-styling) - [Custom CSS Class and ID](#custom-css-class-and-id) - [Using Unordered/Ordered lists](#using-unorderedordered-lists) - [Alternative Tools](#alternative-tools) ## Installation Add jekyll-toc plugin in your site's `Gemfile`, and run `bundle install`. ```ruby gem 'jekyll-toc' ``` Add jekyll-toc to the `gems:` section in your site's `_config.yml`. ```yml plugins: - jekyll-toc ``` Set `toc: true` in posts for which you want the TOC to appear. ```yml --- layout: post title: "Welcome to Jekyll!" toc: true --- ``` ## Usage There are three Liquid filters, which can be applied to HTML content, e.g. the Liquid variable `content` available in Jekyll's templates. ### Basic Usage #### `toc` filter Add the `toc` filter to your site's `{{ content }}` (e.g. `_layouts/post.html`). ```liquid {{ content | toc }} ``` This filter places the TOC directly above the content. ### Advanced Usage If you'd like separated TOC and content, you can use `{% toc %}` tag (or `toc_only` filter) and `inject_anchors` filter. #### `{% toc %}` tag / `toc_only` filter Generates the TOC itself as described [below](#generated-html). Mostly useful in cases where the TOC should _not_ be placed immediately above the content but at some other place of the page, i.e. an aside. ```html
{% toc %}
{{ content }}
``` :warning: **`{% toc %}` Tag Limitation** `{% toc %}` works only for [Jekyll Posts](https://jekyllrb.com/docs/step-by-step/08-blogging/) and [Jekyll Collections](https://jekyllrb.com/docs/collections/). If you'd like to use `{% toc %}` except posts or collections, please use `toc_only` filter as described below. ```html
{{ content | toc_only }}
{{ content | inject_anchors }}
``` #### `inject_anchors` filter Injects HTML anchors into the content without actually outputting the TOC itself. They are of the form: ```html ``` This is only useful when the TOC itself should be placed at some other location with the `toc_only` filter. ## Generated HTML jekyll-toc generates an unordered list by default. The HTML output is as follows. ```html ``` ![screenshot](https://user-images.githubusercontent.com/803398/28401295-0dcfb7ca-6d54-11e7-892b-2f2e6ca755a7.png) ## Customization jekyll-toc is customizable on `_config.yml`. ### Default Configuration ```yml # _config.yml toc: min_level: 1 max_level: 6 ordered_list: false no_toc_section_class: no_toc_section list_id: toc list_class: section-nav sublist_class: '' item_class: toc-entry item_prefix: toc- ``` ### TOC levels ```yml # _config.yml toc: min_level: 2 # default: 1 max_level: 5 # default: 6 ``` The default heading range is from `

` to `

`. ### Enable TOC by default You can enable TOC by default with [Front Matter Defaults](https://jekyllrb.com/docs/configuration/front-matter-defaults/): ```yml # _config.yml defaults: - scope: path: "" values: toc: true ``` ### Skip TOC The heading is ignored in the toc by adding `no_toc` class. ```html

h1

This heading is ignored in the TOC

h2

``` ### Skip TOC Sectionally The headings are ignored inside the element which has `no_toc_section` class. ```html

h1

This heading is ignored in the TOC

This heading is ignored in the TOC

h4

``` Which would result in only the `

` & `

` within the example being included in the TOC. The class can be configured on `_config.yml`: ```yml # _config.yml toc: no_toc_section_class: exclude # default: no_toc_section ``` Configuring multiple classes are allowed: ```yml # _config.yml toc: no_toc_section_class: - no_toc_section - exclude - your_custom_skip_class_name ``` ### CSS Styling The toc can be modified with CSS. The sample CSS is the following. ```css .section-nav { background-color: #fff; margin: 5px 0; padding: 10px 30px; border: 1px solid #e8e8e8; border-radius: 3px; } ``` ![screenshot](https://user-images.githubusercontent.com/803398/28401455-0ba60868-6d55-11e7-8159-0ae7591aee66.png) Each TOC `li` entry has two CSS classes for further styling. The general `toc-entry` is applied to all `li` elements in the `ul.section-nav`. Depending on the heading level each specific entry refers to, it has a second CSS class `toc-XX`, where `XX` is the HTML heading tag name. For example, the TOC entry linking to a heading `

...

` (a single `#` in Markdown) will get the CSS class `toc-h1`. ### Custom CSS Class and ID You can apply custom CSS classes to the generated `