@unlaxer/dde-toolkit 0.1.7 → 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.
- package/lib/dictionary.js +27 -1
- package/package.json +1 -1
- package/version.txt +1 -1
package/lib/dictionary.js
CHANGED
|
@@ -110,7 +110,33 @@ export function buildDictionary(glossaryDir, dictionaryPath, lang = 'en') {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
|
|
113
|
-
// 3.
|
|
113
|
+
// 3. .ja.md の H1 から日本語用語を自動補完
|
|
114
|
+
// dictionary.yaml に ja: エントリがない .ja.md が対象(lang=ja のみ)
|
|
115
|
+
if (lang === 'ja' && existsSync(glossaryDir)) {
|
|
116
|
+
const jaFiles = readdirSync(glossaryDir).filter(f => f.endsWith('.ja.md') && f !== 'README.ja.md');
|
|
117
|
+
for (const jaFile of jaFiles) {
|
|
118
|
+
const jaFilePath = join(glossaryDir, jaFile);
|
|
119
|
+
// 既に ja: エントリがあればスキップ
|
|
120
|
+
if (entries.some(e => e.file === jaFilePath && e.lang === 'ja')) continue;
|
|
121
|
+
// H1 から日本語用語を抽出
|
|
122
|
+
try {
|
|
123
|
+
const content = readFileSync(jaFilePath, 'utf8');
|
|
124
|
+
const h1Match = content.match(/^#\s+(.+)$/m);
|
|
125
|
+
if (!h1Match) continue;
|
|
126
|
+
const jaTerm = h1Match[1]
|
|
127
|
+
.replace(/([^)]*)/g, '') // 全角括弧内を削除
|
|
128
|
+
.replace(/\([^)]*\)/g, '') // 半角括弧内を削除
|
|
129
|
+
.trim();
|
|
130
|
+
if (jaTerm) {
|
|
131
|
+
entries.push({ term: jaTerm, file: jaFilePath, lang: 'ja' });
|
|
132
|
+
}
|
|
133
|
+
} catch {
|
|
134
|
+
// 読み取り失敗は無視
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// 4. 文字数降順ソート(最長一致のため)
|
|
114
140
|
entries.sort((a, b) => b.term.length - a.term.length);
|
|
115
141
|
|
|
116
142
|
return entries;
|
package/package.json
CHANGED
package/version.txt
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.8
|