Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F14844127
D15864.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D15864.diff
View Options
diff --git a/src/applications/differential/mail/DifferentialInlineCommentMailView.php b/src/applications/differential/mail/DifferentialInlineCommentMailView.php
--- a/src/applications/differential/mail/DifferentialInlineCommentMailView.php
+++ b/src/applications/differential/mail/DifferentialInlineCommentMailView.php
@@ -376,13 +376,15 @@
if ($is_html) {
$style = array(
'font: 11px/15px "Menlo", "Consolas", "Monaco", monospace;',
+ 'white-space: pre-wrap;',
+ 'clear: both;',
'padding: 4px 0;',
'margin: 0;',
);
$style = implode(' ', $style);
$patch = phutil_tag(
- 'pre',
+ 'div',
array(
'style' => $style,
),
diff --git a/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php b/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
--- a/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
+++ b/src/applications/differential/render/DifferentialChangesetOneUpMailRenderer.php
@@ -50,6 +50,7 @@
protected function renderPrimitives(array $primitives, $rows) {
$out = array();
+
foreach ($primitives as $k => $p) {
$type = $p['type'];
switch ($type) {
@@ -73,26 +74,66 @@
}
}
- $style = "padding: 0 8px; margin: 0 4px; {$style}";
-
- $out[] = phutil_tag(
- 'div',
- array(
- 'style' => $style,
- ),
- $p['render']);
+ $out[] = array(
+ 'style' => $style,
+ 'render' => $p['render'],
+ 'text' => (string)$p['render'],
+ );
break;
default:
break;
}
}
+ // Remove all leading and trailing empty lines, since these just look kind
+ // of weird in mail.
+ foreach ($out as $key => $line) {
+ if (!strlen(trim($line['text']))) {
+ unset($out[$key]);
+ } else {
+ break;
+ }
+ }
+
+ $keys = array_reverse(array_keys($out));
+ foreach ($keys as $key) {
+ $line = $out[$key];
+ if (!strlen(trim($line['text']))) {
+ unset($out[$key]);
+ } else {
+ break;
+ }
+ }
+
+ // If the user has commented on an empty line in the middle of a bunch of
+ // other empty lines, emit an explicit marker instead of just rendering
+ // nothing.
+ if (!$out) {
+ $out[] = array(
+ 'style' => 'color: #888888;',
+ 'render' => pht('(Empty.)'),
+ );
+ }
+
+ $render = array();
+ foreach ($out as $line) {
+ $style = $line['style'];
+ $style = "padding: 0 8px; margin: 0 4px; {$style}";
+
+ $render[] = phutil_tag(
+ 'div',
+ array(
+ 'style' => $style,
+ ),
+ $line['render']);
+ }
+
$style_map = id(new PhabricatorDefaultSyntaxStyle())
->getRemarkupStyleMap();
$styled_body = id(new PhutilPygmentizeParser())
->setMap($style_map)
- ->parse((string)hsprintf('%s', $out));
+ ->parse((string)hsprintf('%s', $render));
return phutil_safe_html($styled_body);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 3, 1:20 PM (19 h, 23 m)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7086990
Default Alt Text
D15864.diff (3 KB)
Attached To
Mode
D15864: Improve inline mail snippet rendering, possibly fixing Airmail?
Attached
Detach File
Event Timeline
Log In to Comment