diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev
index 31b93df1426..8bc2fc41bc1 100644
--- a/mozilla/webtools/bugzilla/.bzrrev
+++ b/mozilla/webtools/bugzilla/.bzrrev
@@ -1 +1 @@
-9189
\ No newline at end of file
+9190
\ No newline at end of file
diff --git a/mozilla/webtools/bugzilla/.gitrev b/mozilla/webtools/bugzilla/.gitrev
index 4ec8b83e5a1..6ace285bde6 100644
--- a/mozilla/webtools/bugzilla/.gitrev
+++ b/mozilla/webtools/bugzilla/.gitrev
@@ -1 +1 @@
-2fbc1045f5b8e82d9a68328c35ba07d70d9d1877
\ No newline at end of file
+1f5404213d4b93ef573e99112536ed5af6643770
\ No newline at end of file
diff --git a/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm b/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm
index 3023d98e24a..353c2ff6aef 100644
--- a/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm
+++ b/mozilla/webtools/bugzilla/Bugzilla/Markdown.pm
@@ -99,7 +99,7 @@ sub _RunSpanGamut {
$text = $self->_EncodeAmpsAndAngles($text);
$text = $self->_DoItalicsAndBold($text);
- $text =~ s/ {2,}\n/
{empty_element_suffix}\n/g;
+ $text =~ s/\n/
{empty_element_suffix}\n/g;
return $text;
}
@@ -323,13 +323,6 @@ sub _DoItalicsAndBold {
return $text;
}
-# Override this function to ignore 'wrap_in_p_tags' from
-# the caller and to not generate
tags around the output.
-sub _FormParagraphs {
- my ($self, $text) = @_;
- return $self->SUPER::_FormParagraphs($text, { wrap_in_p_tags => 0 });
-}
-
sub _DoStrikethroughs {
my ($self, $text) = @_;
diff --git a/mozilla/webtools/bugzilla/Bugzilla/User.pm b/mozilla/webtools/bugzilla/Bugzilla/User.pm
index acedc65f2a3..fa267436618 100644
--- a/mozilla/webtools/bugzilla/Bugzilla/User.pm
+++ b/mozilla/webtools/bugzilla/Bugzilla/User.pm
@@ -632,6 +632,14 @@ sub is_bug_ignored {
return (grep {$_->{'id'} == $bug_id} @{$self->bugs_ignored}) ? 1 : 0;
}
+sub use_markdown {
+ my ($self, $comment) = @_;
+ return Bugzilla->feature('markdown')
+ && $self->settings->{use_markdown}->{is_enabled}
+ && $self->settings->{use_markdown}->{value} eq 'on'
+ && (!defined $comment || $comment->is_markdown);
+}
+
##########################
# Saved Recent Bug Lists #
##########################
@@ -2623,6 +2631,12 @@ C The current summary of the bug.
Returns true if the user does not want email notifications for the
specified bug ID, else returns false.
+=item C
+
+Returns true if the user has set their preferences to use Markdown
+for rendering comments. If an optional C object is passed
+then it returns true if the comment has markdown enabled.
+
=back
=head2 Saved Recent Bug Lists
diff --git a/mozilla/webtools/bugzilla/js/field.js b/mozilla/webtools/bugzilla/js/field.js
index 1cd58a69ac9..c24603988f0 100644
--- a/mozilla/webtools/bugzilla/js/field.js
+++ b/mozilla/webtools/bugzilla/js/field.js
@@ -984,18 +984,32 @@ function initDirtyFieldTracking() {
var last_comment_text = '';
var last_markdown_cb_value = null;
+var comment_textarea_width = null;
+var comment_textarea_height = null;
-function show_comment_preview(bug_id) {
+function refresh_markdown_preview (bug_id) {
+ if (!YAHOO.util.Dom.hasClass('comment_preview_tab', 'active_comment_tab'))
+ return;
+ show_comment_preview(bug_id, 1);
+}
+
+function show_comment_preview(bug_id, refresh) {
var Dom = YAHOO.util.Dom;
var comment = document.getElementById('comment');
var preview = document.getElementById('comment_preview');
var markdown_cb = document.getElementById('use_markdown');
if (!comment || !preview) return;
- if (Dom.hasClass('comment_preview_tab', 'active_comment_tab')) return;
+ if (Dom.hasClass('comment_preview_tab', 'active_comment_tab') && !refresh)
+ return;
- preview.style.width = (comment.clientWidth - 4) + 'px';
- preview.style.height = comment.offsetHeight + 'px';
+ if (!comment_textarea_width) {
+ comment_textarea_width = (comment.clientWidth - 4) + 'px';
+ comment_textarea_height = comment.offsetHeight + 'px';
+ }
+
+ preview.style.width = comment_textarea_width;
+ preview.style.height = comment_textarea_height;
var comment_tab = document.getElementById('comment_tab');
Dom.addClass(comment, 'bz_default_hidden');
@@ -1029,6 +1043,12 @@ function show_comment_preview(bug_id) {
document.getElementById('comment_preview_text').innerHTML = data.result.html;
Dom.addClass('comment_preview_loading', 'bz_default_hidden');
Dom.removeClass('comment_preview_text', 'bz_default_hidden');
+ if (markdown_cb.checked) {
+ Dom.removeClass('comment_preview_text', 'comment_preview_pre');
+ }
+ else {
+ Dom.addClass('comment_preview_text', 'comment_preview_pre');
+ }
last_comment_text = comment.value;
last_markdown_cb_value = markdown_cb.checked;
}
diff --git a/mozilla/webtools/bugzilla/process_bug.cgi b/mozilla/webtools/bugzilla/process_bug.cgi
index b47a3b1cfce..b3d9799602a 100755
--- a/mozilla/webtools/bugzilla/process_bug.cgi
+++ b/mozilla/webtools/bugzilla/process_bug.cgi
@@ -233,8 +233,8 @@ if (should_set('keywords')) {
$set_all_fields{keywords}->{$action} = $cgi->param('keywords');
}
if (should_set('comment')) {
- my $is_markdown = ($user->settings->{use_markdown}->{is_enabled} &&
- $cgi->param('use_markdown')) ? 1 : 0;
+ my $is_markdown = ($user->use_markdown
+ && $cgi->param('use_markdown') eq '1') ? 1 : 0;
$set_all_fields{comment} = {
body => scalar $cgi->param('comment'),
diff --git a/mozilla/webtools/bugzilla/skins/standard/global.css b/mozilla/webtools/bugzilla/skins/standard/global.css
index 28c406b1d14..60e06af7383 100644
--- a/mozilla/webtools/bugzilla/skins/standard/global.css
+++ b/mozilla/webtools/bugzilla/skins/standard/global.css
@@ -319,7 +319,7 @@ div#docslinks {
}
/* tbody.file pre is for the Diff view of attachments. */
-.bz_comment_text, .uneditable_textarea, tbody.file pre {
+pre.bz_comment_text, .uneditable_textarea, tbody.file pre {
font-family: monospace;
white-space: pre-wrap;
}
@@ -732,6 +732,10 @@ input.required, select.required, span.required_explanation {
width: auto;
}
+.comment_preview_pre {
+ white-space: pre;
+}
+
#comment_preview_loading {
font-style: italic;
}
diff --git a/mozilla/webtools/bugzilla/template/en/default/bug/comment.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/bug/comment.html.tmpl
index b748b71fd16..76054f92ab2 100644
--- a/mozilla/webtools/bugzilla/template/en/default/bug/comment.html.tmpl
+++ b/mozilla/webtools/bugzilla/template/en/default/bug/comment.html.tmpl
@@ -32,14 +32,15 @@
[% END %]
-[% IF feature_enabled('markdown') AND user.settings.use_markdown.value == 'on' %]
+[% IF user.use_markdown %]
diff --git a/mozilla/webtools/bugzilla/template/en/default/bug/comments.html.tmpl b/mozilla/webtools/bugzilla/template/en/default/bug/comments.html.tmpl
index 617f494713c..3895691d75d 100644
--- a/mozilla/webtools/bugzilla/template/en/default/bug/comments.html.tmpl
+++ b/mozilla/webtools/bugzilla/template/en/default/bug/comments.html.tmpl
@@ -267,12 +267,12 @@
[%# Don't indent the block, since then the spaces are displayed in the
# generated HTML
#%]
-
+[% user.use_markdown(comment) ? "div" : "pre" %]>
[% Hook.process('a_comment-end', 'bug/comments.html.tmpl') %]
[% END %]