Commit 3f112b4b336f7dde8c9caaa27ee974966044adf2
1 parent
c4fb48bb
Exists in
staging
and in
4 other branches
comment_paragraph: minor fixes
Showing
1 changed file
with
13 additions
and
2 deletions
Show diff stats
plugins/comment_paragraph/lib/comment_paragraph_plugin.rb
@@ -53,8 +53,19 @@ class CommentParagraphPlugin < Noosfero::Plugin | @@ -53,8 +53,19 @@ class CommentParagraphPlugin < Noosfero::Plugin | ||
53 | 53 | ||
54 | doc = Hpricot(@article.body) | 54 | doc = Hpricot(@article.body) |
55 | paragraphs = doc.search("/*").each do |paragraph| | 55 | paragraphs = doc.search("/*").each do |paragraph| |
56 | - parsed_paragraphs << (paragraph.to_html =~ /^\n|\r\n|<p>\W<\/p>$|(.*)paragraph_comment_spacer(.*)|<div(.*)paragraph_comment(.*)$/ ? paragraph.to_html : CommentParagraphPlugin.parse_paragraph(paragraph.to_html, paragraph_id)) | 56 | + |
57 | + if paragraph.to_html =~ /^<div(.*)paragraph_comment(.*)$/ || paragraph.to_html =~ /^<p>\W<\/p>$/ | ||
58 | + parsed_paragraphs << paragraph.to_html | ||
59 | + else | ||
60 | + if paragraph.to_html =~ /^(<div|<table|<p|<ul).*/ | ||
61 | + parsed_paragraphs << CommentParagraphPlugin.parse_paragraph(paragraph.to_html, paragraph_id) | ||
62 | + else | ||
63 | + parsed_paragraphs << paragraph.to_html | ||
64 | + end | ||
65 | + end | ||
66 | + | ||
57 | paragraph_id += 1 | 67 | paragraph_id += 1 |
68 | + | ||
58 | end | 69 | end |
59 | 70 | ||
60 | @article.body = parsed_paragraphs.join() | 71 | @article.body = parsed_paragraphs.join() |
@@ -75,7 +86,7 @@ class CommentParagraphPlugin < Noosfero::Plugin | @@ -75,7 +86,7 @@ class CommentParagraphPlugin < Noosfero::Plugin | ||
75 | "<div class='macro article_comments paragraph_comment' " + | 86 | "<div class='macro article_comments paragraph_comment' " + |
76 | "data-macro='comment_paragraph_plugin/allow_comment' " + | 87 | "data-macro='comment_paragraph_plugin/allow_comment' " + |
77 | "data-macro-paragraph_id='#{paragraph_id}'>#{paragraph_content}</div>\r\n" + | 88 | "data-macro-paragraph_id='#{paragraph_id}'>#{paragraph_content}</div>\r\n" + |
78 | - "<p class='paragraph_comment_spacer'> </p>\r\n" | 89 | + "<p> </p>" |
79 | end | 90 | end |
80 | 91 | ||
81 | end | 92 | end |