makeup
Advanced tools
+2
-2
| PATH | ||
| remote: . | ||
| specs: | ||
| makeup (0.4.0) | ||
| makeup (0.4.1) | ||
| github-linguist (~> 2.8) | ||
@@ -25,3 +25,3 @@ github-markup (~> 0.7) | ||
| htmlentities (4.3.1) | ||
| mime-types (1.23) | ||
| mime-types (1.24) | ||
| minitest (2.12.1) | ||
@@ -28,0 +28,0 @@ multi_json (1.7.7) |
@@ -40,8 +40,7 @@ # encoding: utf-8 | ||
| lexer = Pygments::Lexer.find(options[:lexer]) | ||
| code = lexer.nil? ? code : Pygments.highlight(code, highlight_options(options)) | ||
| CodeBlock.new(lexer && lexer.aliases.first, code) | ||
| rescue MentosError => e | ||
| # "MentosError" is what Pyments.rb raises when an unknown lexer is | ||
| # attempted used | ||
| CodeBlock.new(nil, @entities.encode(code)) | ||
| return unknown_lexer(code) unless lexer | ||
| code = Pygments.highlight(code, highlight_options(options)) | ||
| CodeBlock.new(lexer.aliases.first, code) | ||
| rescue MentosError | ||
| unknown_lexer(code) | ||
| end | ||
@@ -59,2 +58,7 @@ | ||
| private | ||
| def unknown_lexer(code) | ||
| CodeBlock.new(nil, @entities.encode(code)) | ||
| end | ||
| def highlight_options(options = {}) | ||
@@ -61,0 +65,0 @@ options[:options] ||= {} |
@@ -27,3 +27,3 @@ # encoding: utf-8 | ||
| module Makeup | ||
| VERSION = "0.4.0" | ||
| VERSION = "0.4.1" | ||
| end |
@@ -70,2 +70,8 @@ # encoding: utf-8 | ||
| end | ||
| it "encodes the html entities even with no highliting" do | ||
| html = highlight("file.trololol", "<script>alert('xss')</script>") | ||
| assert_equal "<script>alert('xss')</script>", html | ||
| end | ||
| end | ||
@@ -72,0 +78,0 @@ |