@rip-lang/print 0.1.5 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/print.rip +11 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rip-lang/print",
3
- "version": "0.1.5",
3
+ "version": "0.1.8",
4
4
  "description": "Syntax-highlighted source code printer — Shiki-powered, serves once, auto-opens browser",
5
5
  "type": "module",
6
6
  "main": "print.rip",
package/print.rip CHANGED
@@ -204,7 +204,8 @@ def highlightCode(code, lang)
204
204
  lines = highlighted.split('\n')
205
205
  numbered = lines.map (line, i) ->
206
206
  num = String(i + 1).padStart(4)
207
- "<span class=\"line-num\">#{num}</span> #{line}"
207
+ cls = if i is 0 then 'line-num first' else 'line-num'
208
+ "<span class=\"#{cls}\">#{num}</span> #{line}"
208
209
  numbered.join('\n')
209
210
 
210
211
  sections = []
@@ -313,7 +314,7 @@ html = """
313
314
  <html lang="en">
314
315
  <head>
315
316
  <meta charset="utf-8">
316
- <title>rip-print</title>
317
+ <title>Rip Print - #{new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' })} at #{new Date().toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }).toLowerCase()}</title>
317
318
  <link rel="icon" href="data:,">
318
319
  <style id="hljs-theme">#{defaultCss}</style>
319
320
  <style>
@@ -345,6 +346,7 @@ html = """
345
346
  .code-container pre { margin: 0; border-radius: 0; }
346
347
  .code-container code { font-size: 13px; line-height: 1.5; padding: 0 !important; display: block; }
347
348
  .line-num { color: #aaa; background: #{if dark then '#161b22' else '#f4f4f4'}; user-select: none; display: inline-block; min-width: 2em; text-align: right; padding: 0 0.7em; margin-right: 0.7em; border-right: 1px solid #{borderColor}; }
349
+ .line-num.first { padding-top: 4px; }
348
350
 
349
351
  @media print {
350
352
  .toc { page-break-after: always; }
@@ -372,6 +374,7 @@ html = """
372
374
  };
373
375
  document.getElementById('theme-picker').addEventListener('change', function(e) {
374
376
  var id = e.target.value;
377
+ localStorage.setItem('rip-print-theme', id);
375
378
  var t = themes[id];
376
379
  if (!t) return;
377
380
  document.getElementById('hljs-theme').textContent = t.c;
@@ -391,6 +394,12 @@ html = """
391
394
  document.querySelectorAll('.code-container').forEach(function(e) { e.style.borderColor = brd; });
392
395
  document.querySelectorAll('.toc a').forEach(function(e) { e.style.color = fg; });
393
396
  });
397
+ // Restore saved theme
398
+ var saved = localStorage.getItem('rip-print-theme');
399
+ if (saved && themes[saved]) {
400
+ document.getElementById('theme-picker').value = saved;
401
+ document.getElementById('theme-picker').dispatchEvent(new Event('change'));
402
+ }
394
403
  </script>
395
404
  </body>
396
405
  </html>