heading-case 2.0.0 → 2.0.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/dist/core.js +50 -15
- package/dist/index.js +3 -1
- package/package.json +2 -2
package/dist/core.js
CHANGED
|
@@ -13,14 +13,18 @@ const dict = [
|
|
|
13
13
|
'Agent Skills',
|
|
14
14
|
'API Report File',
|
|
15
15
|
'App Router',
|
|
16
|
+
'Arch Linux',
|
|
16
17
|
'Babel',
|
|
17
18
|
'Baseline',
|
|
19
|
+
'Claude Code',
|
|
18
20
|
'Create React App',
|
|
19
21
|
'Cloudflare Pages',
|
|
20
22
|
'Cloudflare Workers',
|
|
21
23
|
'CSS Modules',
|
|
24
|
+
'Codex',
|
|
22
25
|
'Coding Agent',
|
|
23
26
|
'Coding Agents',
|
|
27
|
+
'Debian',
|
|
24
28
|
'Docusaurus',
|
|
25
29
|
'Docusaurus Faster',
|
|
26
30
|
'EJS',
|
|
@@ -28,10 +32,12 @@ const dict = [
|
|
|
28
32
|
'Fast Refresh',
|
|
29
33
|
'Git',
|
|
30
34
|
'GitHub Actions',
|
|
35
|
+
'GitHub Copilot',
|
|
31
36
|
'GitHub Pages',
|
|
32
37
|
'I',
|
|
33
38
|
'Jest',
|
|
34
39
|
'Lightning CSS',
|
|
40
|
+
'Linux',
|
|
35
41
|
'Lynx',
|
|
36
42
|
'Module Federation',
|
|
37
43
|
'Nextra',
|
|
@@ -64,6 +70,7 @@ const dict = [
|
|
|
64
70
|
'Svelte',
|
|
65
71
|
'Server Action',
|
|
66
72
|
'Service Worker',
|
|
73
|
+
'Shiki',
|
|
67
74
|
'TanStack Router',
|
|
68
75
|
'TanStack Start',
|
|
69
76
|
'Vite',
|
|
@@ -82,27 +89,55 @@ const isTerm = (word, line)=>dict.some((term)=>{
|
|
|
82
89
|
if (term.includes(` ${word}`) || term.includes(`${word} `)) return line.includes(term);
|
|
83
90
|
return term === word;
|
|
84
91
|
});
|
|
92
|
+
const indexCodeSpans = (line)=>{
|
|
93
|
+
const spans = new Map();
|
|
94
|
+
const nextEnds = new Map();
|
|
95
|
+
for(let end = line.length; end > 0;){
|
|
96
|
+
if ('`' !== line[end - 1]) {
|
|
97
|
+
end--;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
let start = end - 1;
|
|
101
|
+
while(start > 0 && '`' === line[start - 1])start--;
|
|
102
|
+
const length = end - start;
|
|
103
|
+
spans.set(start, nextEnds.get(length) ?? end);
|
|
104
|
+
if (length > 1) spans.set(start + 1, nextEnds.get(length - 1) ?? end);
|
|
105
|
+
nextEnds.set(length, end);
|
|
106
|
+
end = start;
|
|
107
|
+
}
|
|
108
|
+
return spans;
|
|
109
|
+
};
|
|
85
110
|
const lineToWords = (line)=>{
|
|
86
111
|
const words = [];
|
|
87
112
|
let lastWord = {
|
|
88
113
|
type: 'word',
|
|
89
114
|
value: ''
|
|
90
115
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
116
|
+
const codeSpans = indexCodeSpans(line);
|
|
117
|
+
for(let index = 0; index < line.length; index++){
|
|
118
|
+
let char = line[index];
|
|
119
|
+
if ('\\' === char && /[\\`]/.test(line[index + 1] ?? '')) char += line[++index];
|
|
120
|
+
else if ('`' === char) {
|
|
121
|
+
const end = codeSpans.get(index);
|
|
122
|
+
char = line.slice(index, end);
|
|
123
|
+
index = end - 1;
|
|
124
|
+
}
|
|
125
|
+
if (/^\s$/.test(char)) if ('space' === lastWord.type) lastWord.value += char;
|
|
126
|
+
else {
|
|
127
|
+
words.push(lastWord);
|
|
128
|
+
lastWord = {
|
|
129
|
+
type: 'space',
|
|
130
|
+
value: char
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
else if ('word' === lastWord.type) lastWord.value += char;
|
|
134
|
+
else {
|
|
135
|
+
words.push(lastWord);
|
|
136
|
+
lastWord = {
|
|
137
|
+
type: 'word',
|
|
138
|
+
value: char
|
|
139
|
+
};
|
|
140
|
+
}
|
|
106
141
|
}
|
|
107
142
|
words.push(lastWord);
|
|
108
143
|
return words;
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,9 @@ const collectWordNodes = (node, words)=>{
|
|
|
7
7
|
};
|
|
8
8
|
const formatHeading = (heading)=>{
|
|
9
9
|
const wordNodes = [];
|
|
10
|
-
|
|
10
|
+
const children = heading.children ?? [];
|
|
11
|
+
const contentNodes = children[0]?.type === 'linkReference' && 'shortcut' === children[0].referenceType ? children.slice(1) : children;
|
|
12
|
+
for (const child of contentNodes)collectWordNodes(child, wordNodes);
|
|
11
13
|
const words = wordNodes.map((node)=>({
|
|
12
14
|
type: 'whitespace' === node.type ? 'space' : 'word',
|
|
13
15
|
value: node.value ?? ''
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "heading-case",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/rstackjs/heading-case"
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
},
|
|
49
49
|
"scripts": {
|
|
50
50
|
"build": "rs lib",
|
|
51
|
-
"bump": "
|
|
51
|
+
"bump": "pnpm version -m \"release: v%s\"",
|
|
52
52
|
"check": "rs check",
|
|
53
53
|
"dev": "rs lib -w",
|
|
54
54
|
"format": "rs fmt",
|