diff --git a/lib/rocco.rb b/lib/rocco.rb index a480366..f6eefa0 100644 --- a/lib/rocco.rb +++ b/lib/rocco.rb @@ -348,9 +348,17 @@ class Rocco to_html. split(/\n*
` blocks.
code_html = code_html.
- split(/\n*#{@options[:comment_chars][:single]} DIVIDER<\/span>\n*/m).
+ split(divider_output).
map { |code| code.sub(/\n?/m, '') }.
map { |code| code.sub(/\n?<\/pre><\/div>\n/m, '') }
diff --git a/test/test_block_comments.rb b/test/test_block_comments.rb
index f814a49..408aff4 100644
--- a/test/test_block_comments.rb
+++ b/test/test_block_comments.rb
@@ -50,7 +50,7 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
r.parse( "\"\"\"\n Comment 1\n\"\"\"\ndef codeblock\nend\n\"\"\"\n Comment 2\n\"\"\"\nif false\nend" )
)
end
- def test_language_without_single_line_comments
+ def test_language_without_single_line_comments_parse
r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
assert_equal(
[
@@ -60,4 +60,39 @@ class RoccoBlockCommentTest < Test::Unit::TestCase
r.parse( "/**\n * Comment 1\n */\ndef codeblock\nend\n/**\n * Comment 2\n */\nif false\nend" )
)
end
+ def test_language_without_single_line_comments_split
+ r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
+ assert_equal(
+ [
+ [ "Comment 1", "Comment 2" ],
+ [ "def codeblock\nend", "if false\nend" ]
+ ],
+ r.split( [
+ [ [ "Comment 1" ], [ "def codeblock", "end" ] ],
+ [ [ "Comment 2" ], [ "if false", "end" ] ]
+ ] )
+ )
+ end
+ def test_language_without_single_line_comments_highlight
+ r = Rocco.new( 'test', '', { :language => "css" } ) { "" } # Generate throwaway instance so I can test `parse`
+
+ highlighted = r.highlight( r.split( r.parse( "/**\n * This is a comment!\n */\n.rule { goes: here; }\n/**\n * Comment 2\n */\n.rule2 { goes: here; }" ) ) )
+ assert_equal(
+ "This is a comment!
",
+ highlighted[0][0]
+ );
+ assert_equal(
+ "Comment 2
\n",
+ highlighted[1][0]
+ );
+ assert(
+ !highlighted[0][1].include?("DIVIDER") &&
+ !highlighted[1][1].include?("DIVIDER"),
+ "`DIVIDER` stripped successfully."
+ )
+
+ assert( true
+ );
+ end
+
end