@rip-lang/print 0.1.0 → 0.1.2
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.
- package/package.json +1 -1
- package/print.rip +8 -5
package/package.json
CHANGED
package/print.rip
CHANGED
|
@@ -216,10 +216,12 @@ for file in allFiles
|
|
|
216
216
|
code = stripTopComments(code) if bypass
|
|
217
217
|
lang = getLang file
|
|
218
218
|
lineCount = code.split('\n').length
|
|
219
|
+
mtime = statSync(file).mtime
|
|
220
|
+
timestamp = mtime.toLocaleDateString('en-US', { year: 'numeric', month: 'short', day: 'numeric' }) + ' at ' + mtime.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit' }).toLowerCase()
|
|
219
221
|
console.log " #{file} (#{lineCount} lines) [#{lang}]"
|
|
220
222
|
highlighted = highlightCode code, lang
|
|
221
223
|
html = "<pre><code class=\"hljs\">#{highlighted}</code></pre>"
|
|
222
|
-
sections.push { file, lineCount, lang, html }
|
|
224
|
+
sections.push { file, lineCount, lang, timestamp, html }
|
|
223
225
|
|
|
224
226
|
# ============================================================================
|
|
225
227
|
# HTML template
|
|
@@ -258,7 +260,7 @@ for section, i in sections
|
|
|
258
260
|
fileSections += """
|
|
259
261
|
<div class="file-section">
|
|
260
262
|
<div class="file-header" id="#{section.file}">
|
|
261
|
-
<span>#{section.file} <span class="meta">(#{section.lineCount} lines) [#{section.lang}]</span></span>
|
|
263
|
+
<span>#{section.file} <span class="meta">(#{section.lineCount} lines) [#{section.lang}] on #{section.timestamp}</span></span>
|
|
262
264
|
<span class="nav">#{nav}</span>
|
|
263
265
|
</div>
|
|
264
266
|
<div class="code-container">
|
|
@@ -270,7 +272,8 @@ for section, i in sections
|
|
|
270
272
|
|
|
271
273
|
# Read highlight.js CSS theme
|
|
272
274
|
hljsTheme = if dark then 'github-dark' else 'github'
|
|
273
|
-
|
|
275
|
+
hljsMain = import.meta.resolve 'highlight.js'
|
|
276
|
+
hljsDir = join hljsMain.replace('file://', '').replace(/\/[^/]+$/, ''), '..', 'styles'
|
|
274
277
|
hljsCss = readFileSync join(hljsDir, "#{hljsTheme}.css"), 'utf-8'
|
|
275
278
|
|
|
276
279
|
html = """
|
|
@@ -305,8 +308,8 @@ html = """
|
|
|
305
308
|
|
|
306
309
|
.code-container { overflow-x: auto; }
|
|
307
310
|
.code-container pre { margin: 0; border-radius: 0; }
|
|
308
|
-
.code-container code { font-size: 13px; line-height: 1.5; padding:
|
|
309
|
-
.line-num { color: #aaa; user-select: none; display: inline-block; min-width: 2em; text-align: right; }
|
|
311
|
+
.code-container code { font-size: 13px; line-height: 1.5; padding: 0 !important; display: block; }
|
|
312
|
+
.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-left: 1px solid #{borderColor}; border-right: 1px solid #{borderColor}; }
|
|
310
313
|
|
|
311
314
|
@media print {
|
|
312
315
|
.toc { page-break-after: always; }
|