heading-case 2.0.1 → 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 +49 -15
- 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',
|
|
@@ -83,27 +89,55 @@ const isTerm = (word, line)=>dict.some((term)=>{
|
|
|
83
89
|
if (term.includes(` ${word}`) || term.includes(`${word} `)) return line.includes(term);
|
|
84
90
|
return term === word;
|
|
85
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
|
+
};
|
|
86
110
|
const lineToWords = (line)=>{
|
|
87
111
|
const words = [];
|
|
88
112
|
let lastWord = {
|
|
89
113
|
type: 'word',
|
|
90
114
|
value: ''
|
|
91
115
|
};
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
}
|
|
107
141
|
}
|
|
108
142
|
words.push(lastWord);
|
|
109
143
|
return words;
|
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",
|