Navigation Menu

Skip to content

Commit

Permalink
A couple more ways you can output the RedCloth version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Garber authored and Jason Garber committed Jul 7, 2008
1 parent e749e1f commit e54e293
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ext/redcloth_scan/redcloth_scan.rl
Expand Up @@ -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; };
Expand Down
2 changes: 1 addition & 1 deletion lib/formatters/base.rb
Expand Up @@ -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)
Expand Down
12 changes: 12 additions & 0 deletions test/test_parser.rb
Expand Up @@ -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 = "<p>RedCloth::VERSION: #{RedCloth::VERSION}</p>"
assert_equal html, RedCloth.new(input).to_html
end

def test_redcloth_version_with_label_2
input = "RedCloth version RedCloth::VERSION"
html = "<p>RedCloth version #{RedCloth::VERSION}</p>"
assert_equal html, RedCloth.new(input).to_html
end

end

0 comments on commit e54e293

Please sign in to comment.