Skip to content

Commit

Permalink
Treat HTML code tags as nowiki tags, too.
Browse files Browse the repository at this point in the history
  • Loading branch information
relistan committed Oct 16, 2010
1 parent ad44fee commit 1d9aba0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ffi/yapwtp.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ def each_template


# Example using Ruby to read a file. Using the above C-implemented methods is barely faster. # Example using Ruby to read a file. Using the above C-implemented methods is barely faster.
File.open("../wikiwiki/wiki-development/\?ContactList", "rb") do |f| File.open("../wikiwiki/wiki-development/\?ContactList", "rb") do |f|
parser.html_from_string (f.read) parser.html_from_string(f.read)
puts "# Templates: #{parser.get_template_count}" puts "# Templates: #{parser.get_template_count}"
puts "-" * 78; puts "-" * 78;
parser.each_template do |template| parser.each_template do |template|
Expand Down
4 changes: 4 additions & 0 deletions spec/test_spec.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -161,6 +161,10 @@ def parse(wikitext, *args)
parse("<pre>'''bold'''</pre>").should == "<p><pre>'''bold'''</pre></p>"; parse("<pre>'''bold'''</pre>").should == "<p><pre>'''bold'''</pre></p>";
end end


it "should treat <code> tags as nowiki tags" do
parse("<code>'''bold'''</code>").should == "<p><code>'''bold'''</code></p>";
end

it "should handle nowiki in complex situations" do it "should handle nowiki in complex situations" do
parse('{| cellspacing="0" border="1" parse('{| cellspacing="0" border="1"
!style="width:50%"|You type !style="width:50%"|You type
Expand Down
6 changes: 4 additions & 2 deletions src/syntax.leg
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -303,12 +303,14 @@ nowiki = nowiki_open < ( !nowiki_close . )* > {
append_to_tag_content("%s", bdata(markup)); append_to_tag_content("%s", bdata(markup));
bdestroy(markup); bdestroy(markup);
} nowiki_close } nowiki_close
nowiki_open = nowiki_open_tag | html_pre_open nowiki_open = nowiki_open_tag | html_pre_open | html_code_open
nowiki_close = nowiki_close_tag | html_pre_close nowiki_close = nowiki_close_tag | html_pre_close | html_code_close
nowiki_open_tag = '<nowiki>' nowiki_open_tag = '<nowiki>'
nowiki_close_tag = '</nowiki>' nowiki_close_tag = '</nowiki>'
html_pre_open = ( '<pre>' | '<PRE>' ) { append_to_tag_content("<pre>"); } html_pre_open = ( '<pre>' | '<PRE>' ) { append_to_tag_content("<pre>"); }
html_pre_close = ( '</pre>' | '</PRE>' ) { append_to_tag_content("</pre>"); } html_pre_close = ( '</pre>' | '</PRE>' ) { append_to_tag_content("</pre>"); }
html_code_open = ( '<code>' | '<CODE>' ) { append_to_tag_content("<code>"); }
html_code_close = ( '</code>' | '</CODE>' ) { append_to_tag_content("</code>"); }


# Links # Links
link = ( local_link | external_link ) { start_of_line = 0; } link = ( local_link | external_link ) { start_of_line = 0; }
Expand Down

0 comments on commit 1d9aba0

Please sign in to comment.