Skip to content
Merged
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
2 changes: 1 addition & 1 deletion lib/sdoc/postprocessor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def guess_code_language(code)
else
"yaml"
end
when /^ *<[%a-z]/i
when /^ *<[%a-z]|%>$|<\/\w+>$/i
"erb" # also highlights HTML
else
"ruby"
Expand Down
13 changes: 13 additions & 0 deletions spec/postprocessor_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,10 @@
<%= 1 + 1 %>
ERB

_(SDoc::Postprocessor.guess_code_language(<<~ERB)).must_equal "erb"
1 + 1 = <%= 1 + 1 %>
ERB

_(SDoc::Postprocessor.guess_code_language(<<~ERB)).must_equal "erb"
<% x = 1 + 1 %>
ERB
Expand All @@ -413,6 +417,10 @@
_(SDoc::Postprocessor.guess_code_language(<<~HTML)).must_equal "erb"
<p>1 + 1 = 2</p>
HTML

_(SDoc::Postprocessor.guess_code_language(<<~HTML)).must_equal "erb"
1 + 1 = <span>2</span>
HTML
end

it "guesses erb for HTML that includes ERB" do
Expand All @@ -432,6 +440,11 @@
Object.new # => #<Object>
RUBY

_(SDoc::Postprocessor.guess_code_language(<<~RUBY)).must_equal "ruby"
Pathname("/span")
# => #<Pathname:/span>
RUBY

_(SDoc::Postprocessor.guess_code_language(<<~RUBY)).must_equal "ruby"
image_tag("image.png")
# => <img src="/assets/image.png" />
Expand Down