|
2 | 2 | {%- assign emailcontent = emailcontent | replace: '<!--excerpt-->', '' %} |
3 | 3 | {% assign blankarray = "" | split: "" %} |
4 | 4 | {% assign emailarray = blankarray %} |
| 5 | +{% capture linebreak %} |
| 6 | +{% endcapture %} |
5 | 7 |
|
6 | 8 | {% assign uljoined = 0 %} |
7 | 9 | {% assign licount = 0 %} |
|
10 | 12 | {% assign rownum = 0 %} |
11 | 13 | {% assign colnum = 0 %} |
12 | 14 | {% assign narrowcol = 0 %} |
| 15 | +{% assign currenttable = 0 %} |
| 16 | +{% assign currenttablediv = 0 %} |
| 17 | +{% assign codeblockend = 0 %} |
| 18 | +{% assign codeblockstart = 0 %} |
| 19 | +{% assign fellowimg = 0 %} |
| 20 | +{% assign tablebody = 0 %} |
13 | 21 |
|
14 | 22 | {%- assign emailnodes = emailcontent | split: '<' %} |
15 | 23 | {% for _node in emailnodes %} |
|
19 | 27 | {% assign nodedesc = subnode[0] | split: ' ' %} |
20 | 28 | {% assign nodename = nodedesc | first %} |
21 | 29 |
|
| 30 | +{% if subnode[1] %}{% assign nodecontent = subnode[1] %}{% endif %} |
| 31 | + |
22 | 32 | {% case nodename %} |
23 | 33 | {% when 'p' %} |
24 | 34 | {% assign emailarray = emailarray | push: '<p align="left" style="font-family: Helvetica, sans-serif; font-size: 10.5pt; color: rgb(0, 0, 0); margin-top: 0px; margin-bottom: 8pt; line-height: 130%; -ms-word-break: break-all; word-break: break-word;">' %} |
|
53 | 63 | {% assign imgct = 1 %} |
54 | 64 | {% if narrowcol == 1 %} |
55 | 65 | {% capture htmlconts %}<{{ subnode[0] | replace: 'alt=', 'width="200" align="center" class="newsletter_template_image" style="max-width: 100%; width: 200px; height: auto !important;" alt=' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}>{% endcapture %} |
| 66 | + {% elsif fellowimg == 1 %} |
| 67 | + {% capture htmlconts %}<{{ subnode[0] | replace: 'padding: 5px;', 'padding: 5px; height: auto !important;' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}>{% endcapture %} |
56 | 68 | {% else %} |
57 | | - {% capture htmlconts %}<{{ subnode[0] | replace: 'alt="Figure', 'width="500" align="center" class="newsletter_template_image" style="max-width: 100%; width: 500px; height: auto !important;" alt="Figure' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}></p>{% endcapture %} |
| 69 | + {% capture htmlconts %}<{{ subnode[0] | replace: 'alt="Figure', 'width="500" align="center" class="newsletter_template_image" style="max-width: 100%; width: 500px; height: auto !important; align: center;" alt="Figure' | replace: 'src="/', 'src="https://scinet.usda.gov/' }}></p>{% endcapture %} |
58 | 70 | {% endif %} |
59 | 71 | {% assign emailarray = emailarray | push: htmlconts %} |
60 | 72 | {% when 'ul' %} |
|
81 | 93 | {% assign uljoined = 0 %} |
82 | 94 | {% endif %} |
83 | 95 | {% assign emailarray = emailarray | push: '</ul>' %} |
| 96 | +{% when 'table' %} |
| 97 | + {% if currenttablediv > currenttable %} |
| 98 | + {% assign emailarray = emailarray | push:'<table cellspacing="0" cellpadding="10" style="border: 1px solid #000000; border-collapse: collapse;">' %} |
| 99 | + {% assign currenttable = currenttable | plus: 1 %} |
| 100 | + {% endif %} |
| 101 | +{% when '/table' %} |
| 102 | + {% if currenttablediv > 0 and currenttablediv == currenttable %} |
| 103 | + {% assign emailarray = emailarray | push:'</table>' %} |
| 104 | + {% assign currenttable = currenttable | minus: 1 %} |
| 105 | + {% endif %} |
| 106 | +{% when 'tbody' %} |
| 107 | + {% assign emailarray = emailarray | push: '<tbody>' %} |
| 108 | + {% assign tablebody = 1 %} |
| 109 | +{% when '/tbody' %} |
| 110 | + {% assign emailarray = emailarray | push: '</tbody>' %} |
| 111 | + {% assign tablebody = 0 %} |
| 112 | +{% when 'td' %} |
| 113 | + {% assign emailarray = emailarray | push: '<td style="border: 1px solid #000000; padding: 10px;" >' %} |
| 114 | +{% when 'th' %} |
| 115 | + {% capture thconts %}<th style="border: 1px solid #000000; padding: 10px; {%- if tablebody == 0 %}background-color: #f1f3f6;" bgcolor="#f1f3f6"{% else %}"{%- endif %} >{% endcapture %} |
| 116 | + {% assign emailarray = emailarray | push: thconts %} |
84 | 117 | {% when 'div' %} |
85 | | - {% if subnode[0] == 'div class="grid-row"' %} |
| 118 | + {% if subnode[0] == 'div class="fellows"' %} |
| 119 | + {% assign fellowimg = 1 %} |
| 120 | + {% elsif subnode[0] == 'div class="grid-row"' %} |
86 | 121 | {% assign rownum = rownum | plus: 1 %} |
87 | 122 | {% assign emailarray = emailarray | push:'<table cellspacing="10"><tbody><tr>' %} |
88 | 123 | {% elsif subnode[0] == 'div class="grid-col-4"' %} |
|
92 | 127 | {% elsif subnode[0] == 'div class="grid-col"' %} |
93 | 128 | {% assign colnum = colnum | plus: 1 %} |
94 | 129 | {% assign emailarray = emailarray | push:'<td>' %} |
| 130 | + {% elsif subnode[0] == 'div class="language-plaintext highlighter-rouge"' %} |
| 131 | + {% assign rownum = rownum | plus: 1 %} |
| 132 | + {% assign emailarray = emailarray | push:'<table cellspacing="10"><tbody><tr>' %} |
| 133 | + {% elsif subnode[0] == 'div class="highlight"' %} |
| 134 | + {% assign emailarray = emailarray | push:'<td bgcolor="#f1f3f6" style="padding: 10px; background-color: #f1f3f6; border: 2px solid #e6e6e6; font-family: monospace, serif; font-size: 10pt; color: rgb(0, 0, 0); line-height: 130%; -ms-word-break: break-all; word-break: break-word;">' %} |
| 135 | + {% assign codeblockstart = 1 %} |
| 136 | + {% elsif subnode[0] == 'div class="usa-table-container flex-scroll"' %} |
| 137 | + {% assign currenttable = 0 %} |
| 138 | + {% assign currenttablediv = currenttablediv | plus: 1 %} |
95 | 139 | {% else %} |
96 | | - <p><b>ALARM</b></p> |
| 140 | + <p><b>ALARM</b></p><code>{{ subnode }}</code> |
97 | 141 | {% endif %} |
98 | 142 | {% when '/div' %} |
99 | | - {% if colnum == rownum %} |
| 143 | + {% if fellowimg == 1 %} |
| 144 | + {% assign fellowimg = 0 %} |
| 145 | + {% elsif codeblockend == 1 %} |
| 146 | + {% assign emailarray = emailarray | push: '</td>' %} |
| 147 | + {% assign codeblockend = 0 %} |
| 148 | + {% elsif currenttable < currenttablediv %} |
| 149 | + {% assign currenttablediv = 0 %} |
| 150 | + {% elsif colnum == rownum %} |
100 | 151 | {% assign narrowcol = 0 %} |
101 | 152 | {% assign emailarray = emailarray | push: '</td>' %} |
102 | 153 | {% assign colnum = colnum | minus: 1 %} |
103 | 154 | {% elsif rownum > colnum %} |
104 | 155 | {% assign rownum = rownum | minus: 1 %} |
105 | 156 | {% assign emailarray = emailarray | push: '</tr></tbody></table>' %} |
106 | 157 | {% else %} |
107 | | - <p><b>ALARM</b></p> |
| 158 | + <p><b>ALARM</b></p><code>{{ subnode }}</code> |
108 | 159 | {% endif %} |
109 | 160 | {% when 'ol' %} |
110 | 161 | {% if licount == 1 %} |
|
119 | 170 | {% assign uljoined = 0 %} |
120 | 171 | {% endif %} |
121 | 172 | {% assign emailarray = emailarray | push: '</ol>' %} |
| 173 | +{% when 'code' %} |
| 174 | + {% assign nodecontent = blankarray %} |
| 175 | + {% assign splitcode = subnode[1] | split: linebreak %} |
| 176 | + {% for _sc in splitcode %} |
| 177 | + {% assign nodecontent = nodecontent | push: _sc %} |
| 178 | + {% unless forloop.last %} |
| 179 | + {% assign nodecontent = nodecontent | push: '<br>' %} |
| 180 | + {% endunless %} |
| 181 | + {% endfor %} |
| 182 | +{% when '/code' %} |
122 | 183 | {% when 'br' %} |
123 | 184 | {% unless imgct == 1 %} |
124 | 185 | {% assign emailarray = emailarray | push: '<br>' %} |
125 | 186 | {% endunless %} |
| 187 | +{% when 'pre' %} |
| 188 | +{% when '/pre' %} |
| 189 | + {% if codeblockstart == 1 %} |
| 190 | + {% assign codeblockstart = 0 %} |
| 191 | + {% assign codeblockend = 1 %} |
| 192 | + {% endif %} |
126 | 193 | {% else %} |
127 | 194 | {% capture thistag %}<{{ nodename }}>{% endcapture %} |
128 | 195 | {% assign emailarray = emailarray | push: thistag %} |
129 | 196 | {% endcase %} |
130 | | -{% if subnode[1] %}{% assign emailarray = emailarray | push: subnode[1] %}{% endif %} |
| 197 | +{% if subnode[1] %}{% assign emailarray = emailarray | push: nodecontent %}{% endif %} |
131 | 198 | {% endif %} |
132 | 199 | {% endfor %} |
133 | 200 |
|
|
0 commit comments