Skip to content

Commit 9b33c1f

Browse files
committed
added :default_colorizer documentation and test case
1 parent 79f8298 commit 9b33c1f

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

lib/nanoc3/filters/colorize_syntax.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,13 @@ class ColorizeSyntax < Nanoc3::Filter
5858
#
5959
# @param [String] content The content to filter
6060
#
61-
# @option params [symbol] :default_colorizer (DEFAULT_COLORIZER) The
61+
# @option params [Symbol] :default_colorizer (DEFAULT_COLORIZER) The
6262
# default colorizer, i.e. the colorizer that will be used when the
6363
# colorizer is not overriden for a specific language.
6464
#
65+
# @option params [Symbol] :syntax (:html) The syntax to use, which can be
66+
# `:html`, `:xml` or `:xhtml`, the latter two being the same.
67+
#
6568
# @option params [Hash] :colorizers ({}) A hash containing
6669
# a mapping of programming languages (symbols, not strings) onto
6770
# colorizers (symbols).

test/filters/test_colorize_syntax.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,24 @@ def test_colorize_syntax_with_xhtml
144144
end
145145
end
146146

147+
def test_colorize_syntax_with_default_colorizer
148+
if `which pygmentize`.strip.empty?
149+
skip 'no pygmentize found, which is required for this test'
150+
return
151+
end
152+
153+
if_have 'nokogiri' do
154+
# Create filter
155+
filter = ::Nanoc3::Filters::ColorizeSyntax.new
156+
157+
# Get input and expected output
158+
input = '<pre><code class="language-ruby">puts "foo"</code></pre>'
159+
expected_output = '<pre><code class="language-ruby"><span class="nb">puts</span> <span class="s2">"foo"</span></code></pre>'
160+
161+
# Run filter
162+
actual_output = filter.run(input, :default_colorizer => :pygmentize)
163+
assert_equal(expected_output, actual_output)
164+
end
165+
end
166+
147167
end

0 commit comments

Comments
 (0)