Skip to content

Commit

Permalink
improved paragraph rendering
Browse files Browse the repository at this point in the history
  • Loading branch information
David Ricciardi committed Jan 30, 2011
1 parent 3e58fbf commit 3741443
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/wikicloth.rb
Expand Up @@ -62,7 +62,7 @@ def render(opt={})
data << "\n" if data.last(1) != "\n"
buffer = WikiBuffer.new("",options)
data.each_char { |c| buffer.add_char(c) }
buffer.to_s
"<p>"+buffer.to_s.gsub(/\n\s*\n/m) { |p| "</p>\n\n<p>" }+"</p>"
end

def to_html(opt={})
Expand Down
6 changes: 2 additions & 4 deletions lib/wikicloth/wiki_buffer.rb
Expand Up @@ -62,7 +62,7 @@ def buffer_type
end

def to_s
"<p>" + self.params.join("\n") + "</p>"
self.params.join("\n")
end

def check_globals()
Expand Down Expand Up @@ -221,11 +221,9 @@ def new_char()
@list_data = cdata
tmp
}
self.data += line + "\n"
self.data += line + ""
end

self.data = "</p><p>" if self.data.blank?

self.params << self.data.auto_link
self.data = ""
else
Expand Down
2 changes: 1 addition & 1 deletion run_tests.rb
Expand Up @@ -29,7 +29,7 @@ class WikiParser < WikiCloth::Parser

@wiki = WikiParser.new({
:params => { "PAGENAME" => "Testing123" },
:data => "\n[[Hello World]] From {{ PAGENAME }} on {{ date }}\n"
:data => "[[Hello World]] From {{ PAGENAME }} on {{ date }}"
})
puts @wiki.to_html

Expand Down
4 changes: 2 additions & 2 deletions test/wiki_cloth_test.rb
Expand Up @@ -173,10 +173,10 @@ class WikiClothTest < ActiveSupport::TestCase
test "disable edit stuff" do
wiki = WikiParser.new(:data => "= Hallo =")
data = wiki.to_html
assert_equal data, "<p>\n<h1><span class=\"editsection\">&#91;<a href=\"?section=Hallo\" title=\"Edit section: Hallo\">edit</a>&#93;</span> <span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1>\n</p>"
assert_equal data, "<p>\n<h1><span class=\"editsection\">&#91;<a href=\"?section=Hallo\" title=\"Edit section: Hallo\">edit</a>&#93;</span> <span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1></p>"

data = wiki.to_html(:noedit => true)
assert_equal data, "<p>\n<h1><span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1>\n</p>"
assert_equal data, "<p>\n<h1><span class=\"mw-headline\" id=\"Hallo\"><a name=\"Hallo\">Hallo</a></span></h1></p>"

end

Expand Down

0 comments on commit 3741443

Please sign in to comment.