diff --git a/.travis.yml b/.travis.yml index 912323b..3b1ba50 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,8 +5,9 @@ rvm: - 2.2 - 2.3.1 - 2.4.0 -# Put this in your .travis.yml +# gemfile is generated by appraisal gemfile: + - gemfiles/jekyll_3.4.gemfile - gemfiles/jekyll_3.3.gemfile - gemfiles/jekyll_3.2.gemfile - gemfiles/jekyll_3.1.gemfile diff --git a/README.md b/README.md index cbaa1c6..a1992fb 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,19 @@ There are three Liquid filters available now, which all should be applied to some HTML content, e.g. the Liquid variable `content` available in Jekyll's templates. -## Basic Usage +## 1. Basic Usage ### `toc` filter Add `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 +## 2. Advanced Usage If you'd like separated TOC and content, you can use `toc_only` and `inject_anchors` filters. diff --git a/lib/table_of_contents/parser.rb b/lib/table_of_contents/parser.rb index 34b149f..17e9795 100644 --- a/lib/table_of_contents/parser.rb +++ b/lib/table_of_contents/parser.rb @@ -1,7 +1,8 @@ module Jekyll module TableOfContents + # Parse html contents and generate table of contents class Parser - PUNCTUATION_REGEXP = RUBY_VERSION > '1.9' ? /[^\p{Word}\- ]/u : /[^\w\- ]/ + PUNCTUATION_REGEXP = /[^\p{Word}\- ]/u attr_reader :doc @@ -11,11 +12,11 @@ def initialize(html) end def build_toc - toc = %Q{