Better HTML email monospace font-size normalization
The default styles of some browsers reduce the font-size of elements with monospace fonts. Previously, this was normalized by setting the font-size of monospaced elements in HTML emails. However, this approach does not always result in consistent font sizes because the normal font size is not known in general (without artificially fixing it). Instead, abstract creation of PRE blocks into a callable private template and set the font-family in a way that is not matched by the default styles. Bug: Issue 4817 Change-Id: I4243a202eda471edaf420d9dc1186c4ed8484c9d
This commit is contained in:
@@ -58,6 +58,7 @@ public class MailSoyTofuProvider implements Provider<SoyTofu> {
|
||||
"MergedHtml.soy",
|
||||
"NewChange.soy",
|
||||
"NewChangeHtml.soy",
|
||||
"Private.soy",
|
||||
"RegisterNewEmail.soy",
|
||||
"ReplacePatchSet.soy",
|
||||
"ReplacePatchSetHtml.soy",
|
||||
@@ -65,7 +66,6 @@ public class MailSoyTofuProvider implements Provider<SoyTofu> {
|
||||
"RestoredHtml.soy",
|
||||
"Reverted.soy",
|
||||
"RevertedHtml.soy",
|
||||
"ViewChangeButton.soy",
|
||||
};
|
||||
|
||||
private final SitePaths site;
|
||||
|
@@ -35,6 +35,6 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -54,7 +54,7 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
|
||||
<ul style="{$ulStyle}">
|
||||
@@ -89,18 +89,20 @@
|
||||
</a>{sp}
|
||||
{/if}
|
||||
{if length($comment.lines) == 1}
|
||||
<code style="font-size:12px">{$comment.lines[0]}</code>
|
||||
<code style="font-family:monospace,monospace">
|
||||
{$comment.lines[0]}
|
||||
</code>
|
||||
{/if}
|
||||
</p>
|
||||
|
||||
{if length($comment.lines) > 1}
|
||||
<p>
|
||||
<blockquote style="{$blockquoteStyle}">
|
||||
<pre style="font-size:12px">
|
||||
{call .Pre}{param content kind="html"}
|
||||
{foreach $line in $comment.lines}
|
||||
{$line}{\n}
|
||||
{/foreach}
|
||||
</pre>
|
||||
{/param}{/call}
|
||||
</blockquote>
|
||||
</p>
|
||||
{/if}
|
||||
|
@@ -39,6 +39,6 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -35,6 +35,6 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -32,17 +32,11 @@
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<pre style="font-size:12px">
|
||||
{$email.changeDetail}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.changeDetail /}{/call}
|
||||
|
||||
<pre style="font-size:12px">
|
||||
{$email.approvals}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.approvals /}{/call}
|
||||
|
||||
{if $email.includeDiff}
|
||||
<pre style="font-size:12px">
|
||||
{$email.unifiedDiff}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.unifiedDiff /}{/call}
|
||||
{/if}
|
||||
{/template}
|
@@ -46,20 +46,16 @@
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<pre style="font-size:12px">
|
||||
{$email.changeDetail}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.changeDetail /}{/call}
|
||||
|
||||
{if $email.sshHost}
|
||||
<pre style="font-size:12px">
|
||||
{call .Pre}{param content kind="html"}
|
||||
git pull ssh:{print '//'}{$email.sshHost}/{$projectName}
|
||||
{sp}{$patchSet.refName}
|
||||
</pre>
|
||||
{/param}{/call}
|
||||
{/if}
|
||||
|
||||
{if $email.includeDiff}
|
||||
<pre style="font-size:12px">
|
||||
{$email.unifiedDiff}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.unifiedDiff /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -16,6 +16,10 @@
|
||||
|
||||
{namespace com.google.gerrit.server.mail.template}
|
||||
|
||||
/*
|
||||
* Private templates that cannot be overridden.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Private template to generate "View Change" buttons.
|
||||
* @param email
|
||||
@@ -32,3 +36,17 @@
|
||||
{/let}
|
||||
<a style="{$visitButtonStyle}" href="{$email.changeUrl}">View Change</a>
|
||||
{/template}
|
||||
|
||||
/**
|
||||
* Private template to render PRE block with consistent font-sizing.
|
||||
* @param content
|
||||
*/
|
||||
{template .Pre private="true" autoescape="strict" kind="html"}
|
||||
{let $preStyle kind="css"}
|
||||
font-family: monospace,monospace; // Use this to avoid browsers scaling down
|
||||
// monospace text.
|
||||
white-space: pre-wrap;
|
||||
{/let}
|
||||
<pre style="{$preStyle}">{$content}</pre>
|
||||
{/template}
|
||||
|
@@ -36,14 +36,12 @@
|
||||
</p>
|
||||
{/if}
|
||||
|
||||
<pre style="font-size:12px">
|
||||
{$email.changeDetail}
|
||||
</pre>
|
||||
{call .Pre}{param content: $email.changeDetail /}{/call}
|
||||
|
||||
{if $email.sshHost}
|
||||
<pre style="font-size:12px">
|
||||
{call .Pre}{param content kind="html"}
|
||||
git pull ssh:{print '//'}{$email.sshHost}/{$projectName}{sp}
|
||||
{$patchSet.refName}
|
||||
</pre>
|
||||
{/param}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -35,6 +35,6 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
@@ -35,6 +35,6 @@
|
||||
{/if}
|
||||
|
||||
{if $coverLetter}
|
||||
<pre style="font-size:12px">{$coverLetter}</pre>
|
||||
{call .Pre}{param content: $coverLetter /}{/call}
|
||||
{/if}
|
||||
{/template}
|
||||
|
Reference in New Issue
Block a user