Skip to content

Commit fb9be57

Browse files
author
Jerry Cheung
committed
Merge remote-tracking branch 'origin/master' into bump-0.1.0
2 parents 045fcdc + 4fc3a60 commit fb9be57

File tree

5 files changed

+19
-9
lines changed

5 files changed

+19
-9
lines changed

.travis.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ rvm:
1010
- 1.8.7
1111
- 1.9.2
1212
- 1.9.3
13-
- ree
13+
- 2.0.0
14+
- ree

lib/html/pipeline/syntax_highlight_filter.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
begin
22
require 'linguist'
33
rescue LoadError
4-
raise LoadError, "You need to install linguist before using the SyntaxHighlightFilter. See README.md for details"
4+
raise LoadError, "You need to install 'github-linguist' before using the SyntaxHighlightFilter. See README.md for details"
55
end
66

77
module HTML

lib/html/pipeline/toc_filter.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ def call
1111
headers = Hash.new(0)
1212
doc.css('h1, h2, h3, h4, h5, h6').each do |node|
1313
name = node.text.downcase
14-
name.gsub!(/[^\w\- ]/, '') # remove punctuation
14+
name.gsub!(/[^\p{Word}\- ]/u, '') # remove punctuation
1515
name.gsub!(' ', '-') # replace spaces with dash
16-
name = EscapeUtils.escape_uri(name) # escape extended UTF-8 chars
1716

1817
uniq = (headers[name] > 0) ? "-#{headers[name]}" : ''
1918
headers[name] += 1
@@ -25,4 +24,4 @@ def call
2524
end
2625
end
2726
end
28-
end
27+
end

test/html/pipeline/absolute_source_filter_test.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,13 @@ def setup
1212
}
1313
end
1414

15-
def test_rewrites_root_relative_urls
15+
def test_rewrites_root_urls
1616
orig = %(<p><img src="/img.png"></p>)
17-
puts AbsoluteSourceFilter.call(orig, @options).to_s
1817
assert_equal "<p><img src=\"#{@image_base_url}/img.png\"></p>",
1918
AbsoluteSourceFilter.call(orig, @options).to_s
2019
end
2120

22-
def test_rewrites_root_relative_urls
21+
def test_rewrites_relative_urls
2322
orig = %(<p><img src="post/img.png"></p>)
2423
assert_equal "<p><img src=\"#{@image_subpage_url}/img.png\"></p>",
2524
AbsoluteSourceFilter.call(orig, @options).to_s

test/html/pipeline/toc_filter_test.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# encoding: utf-8
12
require "test_helper"
23

34
class HTML::Pipeline::TableOfContentsFilterTest < Test::Unit::TestCase
@@ -42,6 +43,16 @@ def test_all_header_tags_are_found_when_adding_anchors
4243
doc = TocFilter.call(orig)
4344
assert_equal 6, doc.search('a').size
4445
end
45-
end
4646

47+
def test_anchors_with_utf8_characters
48+
orig = %(<h1>日本語</h1>
49+
<h1>Русский</h1)
50+
51+
rendered_h1s = TocFilter.call(orig).search('h1').map(&:to_s)
4752

53+
assert_equal "<h1>\n<a name=\"%E6%97%A5%E6%9C%AC%E8%AA%9E\" class=\"anchor\" href=\"#%E6%97%A5%E6%9C%AC%E8%AA%9E\"><span class=\"octicon octicon-link\"></span></a>日本語</h1>",
54+
rendered_h1s[0]
55+
assert_equal "<h1>\n<a name=\"%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9\" class=\"anchor\" href=\"#%D0%A0%D1%83%D1%81%D1%81%D0%BA%D0%B8%D0%B9\"><span class=\"octicon octicon-link\"></span></a>Русский</h1>",
56+
rendered_h1s[1]
57+
end
58+
end

0 commit comments

Comments
 (0)