I'm sending mails when performing some actions, and some of them contain an HTML table.
I wanted to color 1 line out of 2 in the table and for that I'm using the rule below :
tr:nth-child(even) {
background-color: #c4409720;
}
In mailhog the output is perfect and it works but once looking at the email in Outlook or Gmail the rows are not coloured. Note that I don't know how many rows I'll have in advance since the mail template is populated with a list and a loop.
I guess the selector is not supported in those mail clients ?
So how could I achieve this in a way that will be understood by those mail clients ?
Thanks in advance !
As has been pointed out, :nth-child is not supported in Gmail and Outlook, or Yahoo or Protonmail (except PM iOS).
You could achieve this manually via the adjacent selector combinator (e.g. tr + tr), which adds most Gmails (not Gmail accounts without a Gmail address) as well as Yahoo (see https://www.caniemail.com/features/css-selector-adjacent-sibling/)
<style type="text/css">
tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr,
tr + tr + tr,
tr
{background-color:red}
tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr + tr + tr,
tr + tr + tr + tr,
tr + tr
{background-color:transparent}
</style>
Tested with the following table structure:
<table>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
<tr><td>And stuff</td></tr>
</table>
Related
I am trying to sort a file by a date field. I realize this has been done before, however, I cannot find an example that has the following date format.
Canada Goose + 1x03 + For the Triumph of Evil + Sep/30/2013
Rucksack + 10x03 + Everybody's Crying Mercy + Oct/03/13
Test + 4x01 + Season 4, Episode 1 + Jun/01/14
New Family + 3x03 + Double Date + Oct/01/2013
I tried this command but it doesn't work
sort -t '+' -k 4.8,4.11 -k 4.4M -k 4.1,4.2 -b Test.txt
If you have a GNU awk installed, you may want to try this approach.
sort.awk
#!/bin/gawk -f
function convertToSeconds(date, fields) {
split(date, fields, /\//)
fields[1]=months[tolower(fields[1])]
fields[2]=sprintf("%02d", fields[2])
fields[3]=(length(fields[3]) == 2) ? sprintf("2%03d", fields[3]) : fields[3]
return mktime(sprintf("%s %s %s 00 00 00", fields[3], fields[1], fields[2]))
}
BEGIN {
FS="( \\+ )"
months["jan"]="01"; months["feb"]="02"; months["mar"]="03"; months["apr"]="04"
months["may"]="05"; months["jun"]="06"; months["jul"]="07"; months["aug"]="08"
months["sep"]="09"; months["oct"]="10"; months["nov"]="11"; months["dec"]="12"
}
{
arr[convertToSeconds($4)]=$0
}
END {
asorti(arr, dst)
for(i=1; i<=FNR; ++i) {
print arr[dst[i]]
}
}
Give it an execute permission, then run it:
$ chmod +x ./sort.awk
$ ./sort.awk Test.txt
To save the changes into a new file, append this > operator.
$ ./sort.awk Test.txt > SortedTest.txt
** UPDATE 1 **
revised sort key to explicitly list 4 digit year as prefix to circumvent year-end crossover issues
since OP only wants to sort date field, the exact epochs mapping isn't needed at all ::
mawk '$++NF = 366 * ( (_=($3) % 100) + 1900 + 100 * (_<50) ) \
+ int(_ * 10^8) + ($2) + (31) * \
(index(" JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC", toupper($2)) / 3 - 1)'
23284 SEP 30 2013 201300737036
23285 OCT 1 2013 201300737038
23287 OCT 3 2013 201300737040
23541 JUN 14 2014 201400737293
1st column is original date generation order (the correct rank ordering), and the last column is the calculated sort index value - i tested every date from jan 1st 1950 to dec 31 2025, and this simplistic approach ranks order just fine, even though it doesn't bother to calculate exact julian dates, or exact leap years,
since the objective is merely finding a rank ordering method that yields the same sorting output as exact epoch seconds
You're nearly there. Use sed, for example, to add the missing centuries
then the M option of the 2nd KEYDEF field works with GNU sort:
sed 's:/\([0-9][0-9]\)$:/20\1:' << 'HERE' |
f1 + f2 + f3 + NoV/30/15
f1 + f2 + f3 + Sep/30/2013
f1 + f2 + f3 + Oct/03/13
f1 + f2 + f3 + Jun/01/14
f1 + f2 + f3 + Oct/01/2013
f1 + f2 + f3 + mAr/11/11
f1 + f2 + f3 + oct/03/2013
f1 + f2 + f3 + juL/17/1998
HERE
LC_ALL=C sort -t '+' -k 4.9 -k 4.2M,4.4 -k 4.6,4.7
Output:
f1 + f2 + f3 + juL/17/1998
f1 + f2 + f3 + mAr/11/2011
f1 + f2 + f3 + Sep/30/2013
f1 + f2 + f3 + Oct/01/2013
f1 + f2 + f3 + Oct/03/2013
f1 + f2 + f3 + oct/03/2013
f1 + f2 + f3 + Jun/01/2014
f1 + f2 + f3 + NoV/30/2015
How do I edit command pr
tr [:upper:] [:lower:] < "${FILE}" | tr -d [:digit:] | sort | pr -s' ' -t3 | nl
so that the output looks like this:
1 bcxwhex jbdafn osnu
2 bijly jdofnx uriqcl
3 btgr jz uztyp
4 bwifmn kfaky wfwdz
5 bxgvs kigdo wgdax
6 cfukt lf wgfil
7 cgyqlp lnccknh ypt
8 eocbm njevos zcplnln
9 hgmbc ocndbmr znknpo
10 iawmkbh opder zyezfq
and not like this:
1 bcxwhex jbdafn osnu
2 bijly jdofnx uriqcl
3 btgr jz uztyp
4 bwifmn kfaky wfwdz
5 bxgvs kigdo wgdax
6 cfukt lf wgfil
7 cgyqlp lnccknh ypt
8 eocbm njevos zcplnln
9 hgmbc ocndbmr znknpo
10 iawmkbh opder zyezfq
Don't use -s ' ' if you don't want the columns to separated by a single space.
As an aside, don't use upper case for your private variables.
You should replace space to tab with tr, before you do nl
tr [:upper:] [:lower:] < "${FILE}" | tr -d [:digit:] | sort | pr -s' ' -t3 | tr ' ' \\t| nl
And that will tidy up the spaces for you
I want to create an external table with set of text files. Each row should be one text files. Example of one text file is as below and there can be multiple text files.(files are stored in HDFS)
thanking
you
for
the
participation
Lines are terminated by /n. I want to create an external table with the above text files and data in a text file should be in one row(one cell).
I tried the following Create table statement.
Create External table if not exists sample_email(
email STRING
)
STORED AS TEXTFILE
LOCATION '/tmp/txt/sample/';
It will give create table as follows.
+--------------------------------------+
+ email +
+--------------------------------------+
+ thanking +
+--------------------------------------+
+ you +
+--------------------------------------+
+ for +
+--------------------------------------+
+ the +
+--------------------------------------+
+participation +
+--------------------------------------+
+please +
+--------------------------------------+
+find +
+--------------------------------------+
+the +
+--------------------------------------+
+discussed +
+--------------------------------------+
+points +
+--------------------------------------+
But I want as follows.
+--------------------------------------+
+ email +
+--------------------------------------+
+ thanking you for the participation +
+--------------------------------------+
+ please find the discussed points +
+--------------------------------------+
How to overcome my issue?
Thank you in advance
select concat_ws(' ',collect_list(email)) as emails
from sample_email
group by input__file__name
+------------------------------------+
| emails |
+------------------------------------+
| thanking you for the participation |
| please find the discussed points |
+------------------------------------+
Use tr to remove \n from files.
hadoop fs -cat file.txt | tr -d '\n' | hadoop fs -put - new_file.txt
set textinputformat.record.delimiter='\0';
select translate(email,'\n',' ') as emails
from sample_email
+-------------------------------------+
| emails |
+-------------------------------------+
| thanking you for the participation |
| please find the discussed points |
+-------------------------------------+
Unfortunately, I still don't know how to set textinputformat.record.delimiter back to newline within the same session.
How to reset textinputformat.record.delimiter to its default value within hive cli / beeline?
I have this code:
def rectangle
"|------------------|\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"| |\n" +
"|------------------|\n"
end
and I want to refactor it. But for some reason, if I try to concat/merge the strings in any other way "\n" stops working, and it's returned in one line.
def rectangle
a = "|------------------|\n"
b = "| |\n"
a + b + a
end
I tried using
System.getProperty("line.separator", "\n")
as suggested in similar posts, but it's not helpful (or I'm not doing it right). It's part of my course. Feels like I'm missing something obvious.
A simple example is:
def rectangle
a = "|#{'-' * 10}|"
b = "|#{' ' * 10}|"
([a] + [b] * 5 + [a]).join("\n")
end
puts rectangle
I get a mismatched set exception when I try to parse "abc" (the quote marks are part of the input)
Here is the (simplified) grammar - pretty much verbatim from the Java.g example and basically the same from other example grammars. Is there some bug in the latest version? Using 3.2 in the context of eclipse.
Thanks in advance.
grammar String;
options {
language = C;
}
rule: literal EOF;
literal
: CHARLITERAL
| STRINGLITERAL
;
CHARLITERAL
: '\''
( EscapeSequence
| ~( '\'' | '\\' | '\r' | '\n' )
)
'\''
;
STRINGLITERAL
: '"'
( EscapeSequence
| ~( '\\' | '"' | '\r' | '\n' )
)*
'"'
;
fragment
EscapeSequence
: '\\' (
'b'
| 't'
| 'n'
| 'f'
| 'r'
| '\"'
| '\''
| '\\'
|
('0'..'3') ('0'..'7') ('0'..'7')
|
('0'..'7') ('0'..'7')
|
('0'..'7')
)
;
I'm confused by these last edits, but the problem is with the interpreter and is a known problem. Reported in 09.
If the code is generated for the grammar, it works like a charm.
It seems hard to believe that this bug has gone unanswered so long given it's frequency of occurrence.