Sha256: e91c27c125c945cfde553d4ed57e1388dbaac26705524977b9170a52b2cf50a5

Contents?: true

Size: 417 Bytes

Versions: 8

Compression:

Stored size: 417 Bytes

Contents

# frozen_string_literal: true

module Jekyll
  module TableOfContents
    # helper methods for Parser
    module Helper
      PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u.freeze

      def generate_toc_id(text)
        text = text.downcase
                   .gsub(PUNCTUATION_REGEXP, '') # remove punctuation
                   .tr(' ', '-') # replace spaces with dash
        CGI.escape(text)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
jekyll-toc-0.18.0 lib/table_of_contents/helper.rb
jekyll-toc-0.17.1 lib/table_of_contents/helper.rb
jekyll-toc-0.17.0 lib/table_of_contents/helper.rb
jekyll-toc-0.16.1 lib/table_of_contents/helper.rb
jekyll-toc-0.16.0 lib/table_of_contents/helper.rb
jekyll-toc-0.15.0 lib/table_of_contents/helper.rb
jekyll-toc-0.15.0.rc lib/table_of_contents/helper.rb
jekyll-toc-0.14.0 lib/table_of_contents/helper.rb