@clarusjs/content 0.3.1 → 0.4.0
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/dist/index.d.ts +7 -0
- package/dist/index.js +11 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -29,6 +29,13 @@ export type MarkdownOptions = {
|
|
|
29
29
|
tag: string;
|
|
30
30
|
from: string;
|
|
31
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Number the lines of every code block except shell commands (sh, bash, shell, zsh, console, powershell, ps1): a
|
|
34
|
+
* command is copied, not referred to by line. A shell script is numbered: a block with a file title
|
|
35
|
+
* (```bash [deploy.sh]) or a `#!` first line. `:no-line-numbers` turns one block off, `:line-numbers` one on.
|
|
36
|
+
* @see https://clarusjs.com/guide/markdown#code
|
|
37
|
+
*/
|
|
38
|
+
lineNumbers?: boolean;
|
|
32
39
|
/** `::: quiz` is for lessons (frontmatter `steps: true`); 'everywhere' allows it on any page. */
|
|
33
40
|
quizzes?: 'lessons' | 'everywhere';
|
|
34
41
|
/**
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ import MarkdownIt from 'markdown-it';
|
|
|
4
4
|
import { parse as parseYaml } from 'yaml';
|
|
5
5
|
import { highlight } from './highlight.js';
|
|
6
6
|
import { expand } from './snippets.js';
|
|
7
|
+
const SHELL = new Set(['sh', 'bash', 'shell', 'zsh', 'console', 'powershell', 'ps1']);
|
|
7
8
|
function globToRegex(glob) {
|
|
8
9
|
const pattern = glob
|
|
9
10
|
.replace(/[.+?^${}()|[\]\\]/g, '\\$&')
|
|
@@ -187,13 +188,19 @@ function renderer(options) {
|
|
|
187
188
|
delete env.group;
|
|
188
189
|
return '</div>\n';
|
|
189
190
|
};
|
|
191
|
+
md.renderer.rules.table_open = (tokens, i, options, _env, self) => {
|
|
192
|
+
tokens[i].attrSet('tabindex', '0');
|
|
193
|
+
return self.renderToken(tokens, i, options);
|
|
194
|
+
};
|
|
190
195
|
md.renderer.rules.fence = (tokens, i, _o, env) => {
|
|
191
196
|
const e = env;
|
|
192
197
|
const info = tokens[i].info.trim();
|
|
193
198
|
const lang = /^[^\s{[:]+/.exec(info)?.[0] ?? 'text';
|
|
194
199
|
const title = /\[([^\]]+)\]/.exec(info)?.[1];
|
|
195
|
-
const lineNumbers = /(^|\s):line-numbers\b/.test(info);
|
|
196
200
|
const code = tokens[i].content;
|
|
201
|
+
const command = SHELL.has(lang.toLowerCase()) && !title && !code.startsWith('#!');
|
|
202
|
+
const lineNumbers = /(^|\s):line-numbers\b/.test(info) ||
|
|
203
|
+
(!!options.lineNumbers && !command && !/(^|\s):no-line-numbers\b/.test(info));
|
|
197
204
|
let out = '';
|
|
198
205
|
if (e.group) {
|
|
199
206
|
const id = `cl-group-${e.group.id}-${e.group.n}`;
|
|
@@ -279,6 +286,9 @@ function pageHead(data, title) {
|
|
|
279
286
|
tags.push(`<title>${escapeHtml(title)}</title>`);
|
|
280
287
|
if (data.sitemap === false)
|
|
281
288
|
tags.push('<meta name="sitemap" content="false">');
|
|
289
|
+
const lastmod = data.lastmod instanceof Date ? data.lastmod.toISOString().slice(0, 10) : typeof data.lastmod === 'string' ? data.lastmod : undefined;
|
|
290
|
+
if (lastmod !== undefined)
|
|
291
|
+
tags.push(`<meta name="sitemap:lastmod" content="${escapeHtml(lastmod)}">`);
|
|
282
292
|
if (typeof data.image === 'string')
|
|
283
293
|
tags.push(`<meta property="og:image" content="${escapeHtml(data.image)}">`);
|
|
284
294
|
const raws = [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clarusjs/content",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Markdown pages for clarusjs: frontmatter, layouts, components in Markdown, rendered to static HTML at build time.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"access": "public"
|
|
20
20
|
},
|
|
21
21
|
"peerDependencies": {
|
|
22
|
-
"clarusjs": "^0.
|
|
22
|
+
"clarusjs": "^0.13.0"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": "^22.12.0 || ^24.0.0 || >=26.0.0"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/markdown-it": "^14.2.0",
|
|
52
52
|
"@types/node": "^26.6.6",
|
|
53
|
-
"clarusjs": "^0.
|
|
53
|
+
"clarusjs": "^0.13.0",
|
|
54
54
|
"typescript": "^7.0.2",
|
|
55
55
|
"vite": "^8.3.8",
|
|
56
56
|
"vitest": "^5.1.1"
|