@@ -212,19 +212,30 @@ pub async fn gha_logs(
212212 <title>{job_name} - {owner}/{repo}@{short_sha}</title>
213213 {icon_status}
214214 <style>
215+ :root {{
216+ --timestamp-length: 28ch;
217+ }}
215218body {{
216219 font: 14px SFMono-Regular, Consolas, Liberation Mono, Menlo, monospace;
217220 background: #0C0C0C;
218221 color: #CCC;
219222 white-space: pre;
223+ padding-left: calc(var(--timestamp-length) + 1ch);
224+ margin: 0;
220225}}
221226.timestamp {{
222227 color: #848484;
223228 text-decoration: none;
229+ position: absolute;
230+ left: 0;
231+ width: var(--timestamp-length);
224232}}
225233.timestamp:hover {{
226234 text-decoration: underline;
227235}}
236+ .timestamp::before {{
237+ content: attr(data-timestamp);
238+ }}
228239.error-marker {{
229240 scroll-margin-bottom: 15vh;
230241 color: #e5534b;
@@ -276,9 +287,9 @@ body {{
276287 }}
277288
278289 // 3. Add a self-referencial anchor to all timestamps at the start of the lines
279- const dateRegex = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z)/gm;
280- html = html.replace(dateRegex, (ts) =>
281- `<a id="${{ts}}" href="#${{ts}}" class="timestamp"> ${{ts}}</a>`
290+ const dateRegex = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z) /gm;
291+ html = html.replace(dateRegex, (match, ts) =>
292+ `<a id="${{ts}}" href="#${{ts}}" class="timestamp" data-timestamp=" ${{ts}}"> </a>`
282293 );
283294
284295 // 4. Add a anchor around every "##[error]" string
@@ -338,11 +349,9 @@ body {{
338349 }});
339350 }}
340351
341- // 8. Add a copy handler that force plain/text copy and removes the timestamps
342- // from the copied selection.
343- const dateRegexWithSpace = /^(\d{{4}}-\d{{2}}-\d{{2}}T\d{{2}}:\d{{2}}:\d{{2}}\.\d+Z )/gm;
352+ // 8. Add a copy handler that force plain/text copy
344353 document.addEventListener("copy", function(e) {{
345- var text = window.getSelection().toString().replace(dateRegexWithSpace, '') ;
354+ var text = window.getSelection().toString();
346355 e.clipboardData.setData('text/plain', text);
347356 e.preventDefault();
348357 }});
0 commit comments