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

Fix octoicon #4

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
name: Coverage
on: [push]
jobs:
build:
strategy:
matrix:
ruby: [2.6]
runs-on: ubuntu-latest
name: coverage
steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby }}
uses: eregon/use-ruby-action@master
with:
ruby-version: ${{ matrix.ruby }}
- name: bundle install
run: bundle install --jobs 4 --retry 3
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
with:
name: Coverage
on: [push]
jobs:
build:
strategy:
matrix:
ruby: [2.6]
runs-on: ubuntu-latest
name: coverage
steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby }}
uses: eregon/use-ruby-action@master
with:
ruby-version: ${{ matrix.ruby }}
- name: bundle install
run: bundle install --jobs 4 --retry 3
- uses: paambaati/[email protected]
env:
CC_TEST_REPORTER_ID: 6b81e393ea6ad38560386f650ea2fb0e57a7beb5e20f8c8364fabee30d5bff07
with:
coverageCommand: bundle exec rake
36 changes: 18 additions & 18 deletions .github/workflows/rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
name: RuboCop
on: [push]
jobs:
build:
strategy:
matrix:
ruby: [2.6]
runs-on: ubuntu-latest
name: rubocop
steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby }}
uses: eregon/use-ruby-action@master
with:
ruby-version: ${{ matrix.ruby }}
- name: bundle install
run: bundle install --jobs 4 --retry 3
- name: Run RuboCop
name: RuboCop
on: [push]
jobs:
build:
strategy:
matrix:
ruby: [2.6]
runs-on: ubuntu-latest
name: rubocop
steps:
- uses: actions/checkout@v2
- name: Set up Ruby ${{ matrix.ruby }}
uses: eregon/use-ruby-action@master
with:
ruby-version: ${{ matrix.ruby }}
- name: bundle install
run: bundle install --jobs 4 --retry 3
- name: Run RuboCop
run: bundle exec rubocop
18 changes: 18 additions & 0 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ AllCops:
Exclude:
- "*.gemspec"
- "gemfiles/*"
- gems/**/*
- node_modules/**/*
- vendor/bundle/**/*
- Rakefile
- Gemfile

Expand All @@ -21,9 +24,24 @@ Style/WordArray:
Naming/FileName:
Enabled: false

Layout/EndOfLine:
Enabled: false

Layout/LineLength:
Enabled: false

Layout/SpaceAroundMethodCallOperator:
Enabled: false

Lint/StructNewOverride:
Enabled: false

Lint/RaiseException:
Enabled: false

Style/ExponentialNotation:
Enabled: false

Style/HashEachMethods:
Enabled: true

Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ gem 'minitest'
gem 'pry'
gem 'rake'
gem 'rubocop'
gem 'simplecov', '~> 0.17.1'
gem 'simplecov'
2 changes: 1 addition & 1 deletion lib/table_of_contents/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def build_toc
def inject_anchors_into_html
@entries.each do |entry|
# Add id to h-element
entry[:header_parent].set_attribute('id', "#{entry[:id]}")
entry[:header_parent].set_attribute('id', entry[:id].to_s)

entry[:header_content].add_previous_sibling(
%(<a class="anchor" href="##{entry[:id]}" aria-hidden="true">#{@configuration.inject_anchors_content}</a>)
Expand Down
46 changes: 23 additions & 23 deletions test/parser/test_inject_anchors_filter.rb
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# frozen_string_literal: true
require 'test_helper'
class TestInjectAnchorsFilter < Minitest::Test
include TestHelpers
def setup
read_html_and_create_parser
end
def test_injects_anchors_into_content
html = @parser.inject_anchors_into_html
assert_match(%r{<a class="anchor" href="#simple-h1" aria-hidden="true">MyLinkAnchor</a>Simple H1}, html)
end
def test_does_not_inject_toc
html = @parser.inject_anchors_into_html
assert_nil(/<ul id="toc" class="section-nav">/ =~ html)
end
end
# frozen_string_literal: true

require 'test_helper'

class TestInjectAnchorsFilter < Minitest::Test
include TestHelpers

def setup
read_html_and_create_parser
end

def test_injects_anchors_into_content
html = @parser.inject_anchors_into_html

assert_match(%r{<a class="anchor" href="#simple-h1" aria-hidden="true">MyLinkAnchor</a>Simple H1}, html)
end

def test_does_not_inject_toc
html = @parser.inject_anchors_into_html

assert_nil(/<ul id="toc" class="section-nav">/ =~ html)
end
end
72 changes: 36 additions & 36 deletions test/parser/test_toc_filter.rb
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
# frozen_string_literal: true
require 'test_helper'
class TestTOCFilter < Minitest::Test
include TestHelpers
def setup
read_html_and_create_parser
end
def test_injects_anchors
html = @parser.toc
assert_match(%r{<a class="anchor" href="#simple-h1" aria-hidden="true">MyLinkAnchor</a>Simple H1}, html)
end
def test_nested_toc
doc = Nokogiri::HTML(@parser.toc)
nested_h6_text = doc.css('ul.section-nav')
.css('li.toc-h1')
.css('li.toc-h2')
.css('li.toc-h3')
.css('li.toc-h4')
.css('li.toc-h5')
.css('li.toc-h6')
.text
assert_equal('Simple H6', nested_h6_text)
end
def test_injects_toc_container
html = @parser.toc
assert_match(/<ul id="toc" class="section-nav">/, html)
end
end
# frozen_string_literal: true

require 'test_helper'

class TestTOCFilter < Minitest::Test
include TestHelpers

def setup
read_html_and_create_parser
end

def test_injects_anchors
html = @parser.toc

assert_match(%r{<a class="anchor" href="#simple-h1" aria-hidden="true">MyLinkAnchor</a>Simple H1}, html)
end

def test_nested_toc
doc = Nokogiri::HTML(@parser.toc)
nested_h6_text = doc.css('ul.section-nav')
.css('li.toc-h1')
.css('li.toc-h2')
.css('li.toc-h3')
.css('li.toc-h4')
.css('li.toc-h5')
.css('li.toc-h6')
.text
assert_equal('Simple H6', nested_h6_text)
end

def test_injects_toc_container
html = @parser.toc

assert_match(/<ul id="toc" class="section-nav">/, html)
end
end