diff --git a/ext/redcloth_scan/redcloth_scan.rl b/ext/redcloth_scan/redcloth_scan.rl index 7ed4ae60..d8a7487e 100644 --- a/ext/redcloth_scan/redcloth_scan.rl +++ b/ext/redcloth_scan/redcloth_scan.rl @@ -72,7 +72,7 @@ int SYM_escape_preformatted; table = ( tdef? trows >{INLINE(table, table_open);} ) >{ reg = NULL; } ; # info - redcloth_version = "RedCloth::VERSION" (CRLF* EOF | double_return) ; + redcloth_version = ("RedCloth" >A ("::" | " " ) "VERSION"i ":"? " ")? %{STORE(prefix)} "RedCloth::VERSION" (CRLF* EOF | double_return) ; pre_tag := |* pre_tag_end { CAT(block); DONE(block); fgoto main; }; diff --git a/lib/formatters/base.rb b/lib/formatters/base.rb index a04d3660..e25185d6 100644 --- a/lib/formatters/base.rb +++ b/lib/formatters/base.rb @@ -27,7 +27,7 @@ def ignore(opts) alias_method :notextile, :ignore def redcloth_version(opts) - p(:text => RedCloth::VERSION) + p(:text => "#{opts[:prefix]}#{RedCloth::VERSION}") end def method_missing(method, opts) diff --git a/test/test_parser.rb b/test/test_parser.rb index f42bced3..65474aa4 100644 --- a/test/test_parser.rb +++ b/test/test_parser.rb @@ -44,4 +44,16 @@ def test_redcloth_version_only_on_line_by_itself assert_equal html, RedCloth.new(input).to_html end + def test_redcloth_version_with_label + input = "RedCloth::VERSION: RedCloth::VERSION" + html = "

RedCloth::VERSION: #{RedCloth::VERSION}

" + assert_equal html, RedCloth.new(input).to_html + end + + def test_redcloth_version_with_label_2 + input = "RedCloth version RedCloth::VERSION" + html = "

RedCloth version #{RedCloth::VERSION}

" + assert_equal html, RedCloth.new(input).to_html + end + end