henkan 2.4.10 → 2.4.12

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.
@@ -194,15 +194,17 @@ export declare function isGrammar(entry: Result): entry is Grammar;
194
194
  * Generates an array where each field holds an entry’s info wrapped in HTML tags.
195
195
  * @param entry Any type of mapped entry ({@link Word}, {@link Kanji}, {@link Radical}, {@link Kana}, {@link Grammar})
196
196
  * @param customData An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
197
+ * @param additionalTags Additional tags that will be added alongside the existing entry tags
197
198
  * @returns An array of fields, each corresponding to an Anki note type field
198
199
  */
199
- export declare function generateAnkiNote(entry: Result, customData?: string): string[];
200
+ export declare function generateAnkiNote(entry: Result, customData?: string, additionalTags?: string[]): string[];
200
201
  /**
201
202
  * Generates an Anki notes file with each entry’s info organized into fields, either in HTML or plain text.
202
203
  * @param list An array containing any type of transformed entries ({@link Word}, {@link Kanji}, {@link Radical}, {@link Kana}, {@link Grammar})
203
204
  * @param defaultNoteInfo An object with options regarding default values of some note information
204
205
  * @param customData An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
206
+ * @param additionalTags Additional tags that will be added alongside the existing entry tags
205
207
  * @returns The resulting Anki notes file's content
206
208
  */
207
- export declare function generateAnkiNotesFile(list: readonly Result[], defaultNoteInfo?: DefaultNoteInfo, customData?: string): string;
209
+ export declare function generateAnkiNotesFile(list: readonly Result[], defaultNoteInfo?: DefaultNoteInfo, customData?: string, additionalTags?: string[]): string;
208
210
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAYhC,OAAO,EACL,eAAe,EAEf,SAAS,EACT,aAAa,EAIb,qBAAqB,EAErB,WAAW,EACX,WAAW,EAEX,QAAQ,EACR,SAAS,EAET,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CAAC,EAAE,SAAS,kBAAkB,EAAE,GAAG,kBAAkB,EAChE,YAAY,CAAC,EAAE,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,GAChB,IAAI,GAAG,SAAS,CA8gBlB;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI,CAKnD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,OAAO,CAIzD;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,KAAK,CAOrD;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,IAAI,CAInD;AAED,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,IAAI,OAAO,CAIzD;AAoBD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,MAAM,EACb,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB,MAAM,EAAE,CA+ZV;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,eAAe,CAAC,EAAE,eAAe,EACjC,UAAU,CAAC,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EAAE,GACxB,MAAM,CAuIR"}
@@ -6,9 +6,9 @@
6
6
 
7
7
  # Function: generateAnkiNote()
8
8
 
9
- > **generateAnkiNote**(`entry`, `customData?`): `string`[]
9
+ > **generateAnkiNote**(`entry`, `customData?`, `additionalTags?`): `string`[]
10
10
 
11
- Defined in: [utils.ts:2564](https://github.com/Ronokof/Henkan/blob/main/src/utils.ts#L2564)
11
+ Defined in: [utils.ts:2643](https://github.com/Ronokof/Henkan/blob/main/src/utils.ts#L2643)
12
12
 
13
13
  Generates an array where each field holds an entry’s info wrapped in HTML tags.
14
14
 
@@ -26,6 +26,12 @@ Any type of mapped entry ([Word](../interfaces/Word.md), [Kanji](../interfaces/K
26
26
 
27
27
  An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
28
28
 
29
+ ### additionalTags?
30
+
31
+ `string`[]
32
+
33
+ Additional tags that will be added alongside the existing entry tags
34
+
29
35
  ## Returns
30
36
 
31
37
  `string`[]
@@ -6,9 +6,9 @@
6
6
 
7
7
  # Function: generateAnkiNotesFile()
8
8
 
9
- > **generateAnkiNotesFile**(`list`, `defaultNoteInfo?`, `customData?`): `string`
9
+ > **generateAnkiNotesFile**(`list`, `defaultNoteInfo?`, `customData?`, `additionalTags?`): `string`
10
10
 
11
- Defined in: [utils.ts:3023](https://github.com/Ronokof/Henkan/blob/main/src/utils.ts#L3023)
11
+ Defined in: [utils.ts:3072](https://github.com/Ronokof/Henkan/blob/main/src/utils.ts#L3072)
12
12
 
13
13
  Generates an Anki notes file with each entry’s info organized into fields, either in HTML or plain text.
14
14
 
@@ -32,6 +32,12 @@ An object with options regarding default values of some note information
32
32
 
33
33
  An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
34
34
 
35
+ ### additionalTags?
36
+
37
+ `string`[]
38
+
39
+ Additional tags that will be added alongside the existing entry tags
40
+
35
41
  ## Returns
36
42
 
37
43
  `string`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "henkan",
3
- "version": "2.4.10",
3
+ "version": "2.4.12",
4
4
  "description": "Converter & Simplifier for JMdict, KANJIDIC, KRADFILE2, RADKFILE2 and Tanaka Corpus",
5
5
  "keywords": [
6
6
  "fjsd",
@@ -75,15 +75,15 @@
75
75
  "@typescript-eslint/eslint-plugin": "^8.54.0",
76
76
  "@typescript-eslint/parser": "^8.54.0",
77
77
  "@vitest/coverage-v8": "^4.0.18",
78
- "esbuild": "^0.27.2",
78
+ "esbuild": "^0.27.3",
79
79
  "eslint": "^9.39.2",
80
80
  "eslint-plugin-import": "^2.32.0",
81
- "eslint-plugin-jsdoc": "^62.5.0",
81
+ "eslint-plugin-jsdoc": "^62.5.4",
82
82
  "eslint-plugin-prettier": "^5.5.5",
83
83
  "prettier": "^3.8.1",
84
84
  "rimraf": "^6.1.2",
85
85
  "typedoc": "^0.28.16",
86
- "typedoc-plugin-markdown": "^4.9.0",
86
+ "typedoc-plugin-markdown": "^4.10.0",
87
87
  "typescript": "^5.9.3",
88
88
  "vitest": "^4.0.18"
89
89
  },
package/src/utils.ts CHANGED
@@ -2141,12 +2141,28 @@ export function getWord(
2141
2141
 
2142
2142
  word.translations = [];
2143
2143
 
2144
+ const meanings: string[] | undefined =
2145
+ dictWord.hasPhrases === true && examples !== undefined ? [] : undefined;
2146
+ const seenPhrases: Set<string> = new Set<string>();
2147
+
2144
2148
  for (const dictMeaning of dictWord.meanings) {
2145
2149
  const translationTypes: string[] = [];
2146
2150
  const translations: string[] = dictMeaning.translations.map(
2147
2151
  (translation: string | { translation: string; type: string }) => {
2148
- if (typeof translation === "string") return translation;
2149
- else {
2152
+ if (typeof translation === "string") {
2153
+ if (meanings !== undefined) {
2154
+ const cleanTranslation: string = translation
2155
+ .replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "")
2156
+ .trim();
2157
+
2158
+ if (!seenPhrases.has(cleanTranslation)) {
2159
+ seenPhrases.add(cleanTranslation);
2160
+ meanings.push(cleanTranslation);
2161
+ }
2162
+ }
2163
+
2164
+ return translation;
2165
+ } else {
2150
2166
  const translationNoteAndTag:
2151
2167
  | readonly [string, string]
2152
2168
  | readonly [string, string, POS | readonly POS[]] = noteMap.get(
@@ -2156,6 +2172,17 @@ export function getWord(
2156
2172
  translationTypes.push(translationNoteAndTag[1]);
2157
2173
  word.tags!.push(`word::${translationNoteAndTag[0]}`);
2158
2174
 
2175
+ if (meanings !== undefined) {
2176
+ const cleanTranslation: string = translation.translation
2177
+ .replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "")
2178
+ .trim();
2179
+
2180
+ if (!seenPhrases.has(cleanTranslation)) {
2181
+ seenPhrases.add(cleanTranslation);
2182
+ meanings.push(cleanTranslation);
2183
+ }
2184
+ }
2185
+
2159
2186
  return translation.translation;
2160
2187
  }
2161
2188
  },
@@ -2208,6 +2235,8 @@ export function getWord(
2208
2235
  word.tags!.push("word::usually_in_kana_for_all_senses");
2209
2236
  }
2210
2237
 
2238
+ seenPhrases.clear();
2239
+
2211
2240
  if (kanjiDic !== undefined && word.kanjiForms !== undefined) {
2212
2241
  const kanji: Kanji[] = [];
2213
2242
  const seenChars: Set<string> = new Set<string>();
@@ -2240,9 +2269,9 @@ export function getWord(
2240
2269
  if (kanji.length > 0) word.kanji = kanji;
2241
2270
  }
2242
2271
 
2243
- if (dictWord.hasPhrases === true && examples !== undefined) {
2272
+ if (meanings !== undefined) {
2244
2273
  const exampleList: readonly TanakaExample[] =
2245
- examples instanceof Map ? (examples.get(dictWord.id) ?? []) : examples;
2274
+ examples instanceof Map ? (examples.get(dictWord.id) ?? []) : examples!;
2246
2275
 
2247
2276
  const rkf: ReadingsKanjiFormsPair = getValidForms(
2248
2277
  dictWord.readings,
@@ -2258,44 +2287,37 @@ export function getWord(
2258
2287
  ? new Set<string>(rkf.kanjiForms.map((kf: DictKanjiForm) => kf.form))
2259
2288
  : undefined;
2260
2289
 
2261
- const meanings: string[] = new Set<string>(
2262
- dictWord.meanings.flatMap((m: DictMeaning) =>
2263
- m.translations.map((t: DictTranslation) => {
2264
- if (typeof t === "string")
2265
- return t.replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "").trim();
2266
- else
2267
- return t.translation
2268
- .replaceAll(/\([^)]*\)|\[[^\]]*\]|\{[^}]*\}/g, "")
2269
- .trim();
2270
- }),
2271
- ),
2272
- )
2273
- .values()
2274
- .toArray();
2275
-
2276
- let kanjiFormExamples: {
2290
+ let readingMatchingKanjiFormExamples: {
2277
2291
  ex: TanakaExample;
2278
2292
  partIndex: number;
2279
- form?: string | undefined;
2293
+ form: string;
2294
+ referenceIDMatch?: true | undefined;
2280
2295
  includesTranslation?: true | undefined;
2281
2296
  }[] = [];
2282
- const readingMatchingKanjiFormExamples: {
2297
+ let kanjiFormExamples: {
2283
2298
  ex: TanakaExample;
2284
2299
  partIndex: number;
2300
+ form: string;
2301
+ includesTranslation?: true | undefined;
2285
2302
  }[] = [];
2303
+
2286
2304
  let readingExamples: {
2287
2305
  ex: TanakaExample;
2288
2306
  partIndex: number;
2289
2307
  referenceIDMatch?: true | undefined;
2290
2308
  includesTranslation?: true | undefined;
2291
2309
  }[] = [];
2292
- const readingMatchingKanjiForms: Set<string> = new Set<string>();
2293
- const seenPhrases: Set<string> = new Set<string>();
2310
+
2311
+ let hasReadingMatchingKanjiFormWithTranslation: boolean = false;
2294
2312
 
2295
2313
  for (const example of exampleList)
2296
2314
  for (let i: number = 0; i < example.parts.length; i++) {
2297
2315
  if (seenPhrases.has(example.phrase)) break;
2298
2316
 
2317
+ const includesTranslation: boolean = meanings.some((m: string) =>
2318
+ example.translation.includes(m),
2319
+ );
2320
+
2299
2321
  const part: ExamplePart = example.parts[i]!;
2300
2322
 
2301
2323
  const readingAsReadingMatch: boolean =
@@ -2315,19 +2337,22 @@ export function getWord(
2315
2337
  readingMatchingKanjiFormExamples.push({
2316
2338
  ex: example,
2317
2339
  partIndex: i,
2340
+ form: part.baseForm,
2341
+ ...(referenceIDMatch ? { referenceIDMatch: true } : {}),
2342
+ ...(includesTranslation ? { includesTranslation: true } : {}),
2318
2343
  });
2319
2344
 
2320
- readingMatchingKanjiForms.add(part.baseForm);
2345
+ if (
2346
+ !hasReadingMatchingKanjiFormWithTranslation &&
2347
+ includesTranslation
2348
+ )
2349
+ hasReadingMatchingKanjiFormWithTranslation = true;
2321
2350
  } else
2322
2351
  kanjiFormExamples.push({
2323
2352
  ex: example,
2324
2353
  partIndex: i,
2325
2354
  form: part.baseForm,
2326
- ...(meanings.some((m: string) =>
2327
- example.translation.includes(m),
2328
- )
2329
- ? { includesTranslation: true }
2330
- : {}),
2355
+ ...(includesTranslation ? { includesTranslation: true } : {}),
2331
2356
  });
2332
2357
 
2333
2358
  seenPhrases.add(example.phrase);
@@ -2345,10 +2370,7 @@ export function getWord(
2345
2370
  ex: example,
2346
2371
  partIndex: i,
2347
2372
  ...(referenceIDMatch ? { referenceIDMatch: true } : {}),
2348
- ...(!referenceIDMatch &&
2349
- meanings.some((m: string) => example.translation.includes(m))
2350
- ? { includesTranslation: true }
2351
- : {}),
2373
+ ...(includesTranslation ? { includesTranslation: true } : {}),
2352
2374
  });
2353
2375
 
2354
2376
  seenPhrases.add(example.phrase);
@@ -2357,32 +2379,51 @@ export function getWord(
2357
2379
  }
2358
2380
  }
2359
2381
 
2360
- const hasKfExamplesWithTranslation: boolean = kanjiFormExamples.some(
2361
- (ex: {
2362
- ex: TanakaExample;
2363
- partIndex: number;
2364
- form?: string | undefined;
2365
- includesTranslation?: true | undefined;
2366
- }) => ex.includesTranslation === true,
2367
- );
2382
+ if (readingMatchingKanjiFormExamples.length > 0) {
2383
+ if (hasReadingMatchingKanjiFormWithTranslation)
2384
+ readingMatchingKanjiFormExamples =
2385
+ readingMatchingKanjiFormExamples.filter(
2386
+ (ex: {
2387
+ ex: TanakaExample;
2388
+ partIndex: number;
2389
+ form: string;
2390
+ referenceIDMatch?: true | undefined;
2391
+ includesTranslation?: true | undefined;
2392
+ }) =>
2393
+ ex.includesTranslation === true ||
2394
+ ex.referenceIDMatch === true ||
2395
+ ex.ex.parts.some(
2396
+ (part: ExamplePart) =>
2397
+ ex.form === part.baseForm && part.glossNumber !== undefined,
2398
+ ),
2399
+ );
2400
+
2401
+ kanjiFormExamples.length = 0;
2402
+ }
2368
2403
 
2369
- if (kanjiFormExamples.length > 0 && readingMatchingKanjiForms.size > 0)
2404
+ if (
2405
+ kanjiFormExamples.length > 0 &&
2406
+ kanjiFormExamples.some(
2407
+ (ex: {
2408
+ ex: TanakaExample;
2409
+ partIndex: number;
2410
+ form: string;
2411
+ includesTranslation?: true | undefined;
2412
+ }) => ex.includesTranslation === true,
2413
+ )
2414
+ )
2370
2415
  kanjiFormExamples = kanjiFormExamples.filter(
2371
2416
  (ex: {
2372
2417
  ex: TanakaExample;
2373
2418
  partIndex: number;
2374
- form?: string | undefined;
2419
+ form: string;
2375
2420
  includesTranslation?: true | undefined;
2376
2421
  }) =>
2377
- ex.form !== undefined &&
2378
- readingMatchingKanjiForms.has(ex.form) &&
2379
- (!hasKfExamplesWithTranslation ||
2380
- ex.includesTranslation === true ||
2381
- ex.ex.parts.some(
2382
- (part: ExamplePart) =>
2383
- readingMatchingKanjiForms.has(part.baseForm) &&
2384
- part.glossNumber !== undefined,
2385
- )),
2422
+ ex.includesTranslation === true ||
2423
+ ex.ex.parts.some(
2424
+ (part: ExamplePart) =>
2425
+ ex.form === part.baseForm && part.glossNumber !== undefined,
2426
+ ),
2386
2427
  );
2387
2428
 
2388
2429
  if (
@@ -2405,16 +2446,24 @@ export function getWord(
2405
2446
  }) => ex.includesTranslation === true || ex.referenceIDMatch === true,
2406
2447
  );
2407
2448
 
2408
- let wordExamples: { ex: TanakaExample; partIndex: number }[] = [
2449
+ let wordExamples: (
2450
+ | {
2451
+ ex: TanakaExample;
2452
+ partIndex: number;
2453
+ form: string;
2454
+ includesTranslation?: true | undefined;
2455
+ }
2456
+ | {
2457
+ ex: TanakaExample;
2458
+ partIndex: number;
2459
+ referenceIDMatch?: true | undefined;
2460
+ includesTranslation?: true | undefined;
2461
+ }
2462
+ )[] = [
2409
2463
  ...(word.kanjiForms !== undefined
2410
2464
  ? [...readingMatchingKanjiFormExamples, ...kanjiFormExamples]
2411
2465
  : readingExamples),
2412
- ].toSorted(
2413
- (
2414
- a: { ex: TanakaExample; partIndex: number },
2415
- b: { ex: TanakaExample; partIndex: number },
2416
- ) => a.ex.phrase.length - b.ex.phrase.length,
2417
- );
2466
+ ];
2418
2467
 
2419
2468
  seenPhrases.clear();
2420
2469
 
@@ -2447,8 +2496,21 @@ export function getWord(
2447
2496
  if (glossSpecificExamples.length > 0) {
2448
2497
  if (glossSpecificExamples.length < 5) {
2449
2498
  wordExamples = wordExamples.filter(
2450
- (ex: { ex: TanakaExample; partIndex: number }) =>
2451
- !seenPhrases.has(ex.ex.phrase),
2499
+ (
2500
+ ex:
2501
+ | {
2502
+ ex: TanakaExample;
2503
+ partIndex: number;
2504
+ form: string;
2505
+ includesTranslation?: true | undefined;
2506
+ }
2507
+ | {
2508
+ ex: TanakaExample;
2509
+ partIndex: number;
2510
+ referenceIDMatch?: true | undefined;
2511
+ includesTranslation?: true | undefined;
2512
+ },
2513
+ ) => !seenPhrases.has(ex.ex.phrase),
2452
2514
  );
2453
2515
 
2454
2516
  if (wordExamples.length > 0)
@@ -2467,14 +2529,30 @@ export function getWord(
2467
2529
  glossSpecificExamples.length === 0
2468
2530
  ? wordExamples.slice(0, 5)
2469
2531
  : wordExamples
2470
- ).map((ex: { ex: TanakaExample; partIndex: number }) => ({
2471
- phrase: ex.ex.furigana ?? ex.ex.phrase,
2472
- translation: ex.ex.translation,
2473
- originalPhrase: ex.ex.phrase,
2474
- ...(ex.ex.glossNumber !== undefined
2475
- ? { glossNumber: ex.ex.glossNumber }
2476
- : {}),
2477
- }));
2532
+ ).map(
2533
+ (
2534
+ ex:
2535
+ | {
2536
+ ex: TanakaExample;
2537
+ partIndex: number;
2538
+ form: string;
2539
+ includesTranslation?: true | undefined;
2540
+ }
2541
+ | {
2542
+ ex: TanakaExample;
2543
+ partIndex: number;
2544
+ referenceIDMatch?: true | undefined;
2545
+ includesTranslation?: true | undefined;
2546
+ },
2547
+ ) => ({
2548
+ phrase: ex.ex.furigana ?? ex.ex.phrase,
2549
+ translation: ex.ex.translation,
2550
+ originalPhrase: ex.ex.phrase,
2551
+ ...(ex.ex.glossNumber !== undefined
2552
+ ? { glossNumber: ex.ex.glossNumber }
2553
+ : {}),
2554
+ }),
2555
+ );
2478
2556
 
2479
2557
  word.tags!.push("word::has_phrases");
2480
2558
  if (glossSpecificExamples.length > 0)
@@ -2559,9 +2637,14 @@ const createEntry: (
2559
2637
  * Generates an array where each field holds an entry’s info wrapped in HTML tags.
2560
2638
  * @param entry Any type of mapped entry ({@link Word}, {@link Kanji}, {@link Radical}, {@link Kana}, {@link Grammar})
2561
2639
  * @param customData An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
2640
+ * @param additionalTags Additional tags that will be added alongside the existing entry tags
2562
2641
  * @returns An array of fields, each corresponding to an Anki note type field
2563
2642
  */
2564
- export function generateAnkiNote(entry: Result, customData?: string): string[] {
2643
+ export function generateAnkiNote(
2644
+ entry: Result,
2645
+ customData?: string,
2646
+ additionalTags?: string[],
2647
+ ): string[] {
2565
2648
  const fields: string[] = [];
2566
2649
 
2567
2650
  if (isWord(entry)) {
@@ -2798,15 +2881,6 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
2798
2881
  .join("")
2799
2882
  : '<span class="word word-kanji" id="no-kanji">(no kanji)</span>',
2800
2883
  searchField,
2801
- ...(entry.tags !== undefined && entry.tags.length > 0
2802
- ? [
2803
- entry.tags
2804
- .map((tag: string) =>
2805
- tag.trim().toLowerCase().replaceAll(" ", "::"),
2806
- )
2807
- .join(" "),
2808
- ]
2809
- : []),
2810
2884
  );
2811
2885
  }
2812
2886
 
@@ -2847,15 +2921,6 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
2847
2921
  entry.sources !== undefined
2848
2922
  ? `<span class="radical radical-source">${entry.sources.map((source: string, index: number) => `<a href="${source}" target="_blank">Source ${index + 1}</a>`).join("<br>")}</span>`
2849
2923
  : '<span class="radical radical-source" id="no-sources">(no sources)</span>',
2850
- ...(entry.tags !== undefined && entry.tags.length > 0
2851
- ? [
2852
- entry.tags
2853
- .map((tag: string) =>
2854
- tag.trim().toLowerCase().replaceAll(" ", "::"),
2855
- )
2856
- .join(" "),
2857
- ]
2858
- : []),
2859
2924
  );
2860
2925
 
2861
2926
  if (isKanji(entry))
@@ -2928,15 +2993,6 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
2928
2993
  entry.source !== undefined
2929
2994
  ? `<span class="kanji kanji-source"><a href="${entry.source}" target="_blank">Source</a></span>`
2930
2995
  : '<span class="kanji kanji-source" id="no-source">(no components/mnemonic source)</span>',
2931
- ...(entry.tags !== undefined && entry.tags.length > 0
2932
- ? [
2933
- entry.tags
2934
- .map((tag: string) =>
2935
- tag.trim().toLowerCase().replaceAll(" ", "::"),
2936
- )
2937
- .join(" "),
2938
- ]
2939
- : []),
2940
2996
  );
2941
2997
 
2942
2998
  if (isKana(entry))
@@ -2950,15 +3006,6 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
2950
3006
  `<img class="kana kana-stroke-order" src="${entry.svg}" alt="${entry.kana} stroke order SVG">`,
2951
3007
  )
2952
3008
  : "(no stroke order SVG available)",
2953
- ...(entry.tags !== undefined && entry.tags.length > 0
2954
- ? [
2955
- entry.tags
2956
- .map((tag: string) =>
2957
- tag.trim().toLowerCase().replaceAll(" ", "::"),
2958
- )
2959
- .join(" "),
2960
- ]
2961
- : []),
2962
3009
  );
2963
3010
 
2964
3011
  if (isGrammar(entry))
@@ -2999,15 +3046,16 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
2999
3046
  entry.source !== undefined
3000
3047
  ? `<span class="grammar grammar-source"><a href="${entry.source}" target="_blank">Source</a></span>`
3001
3048
  : '<span class="grammar grammar-source" id="no-source">(no source)</span>',
3002
- ...(entry.tags !== undefined && entry.tags.length > 0
3003
- ? [
3004
- entry.tags
3005
- .map((tag: string) =>
3006
- tag.trim().toLowerCase().replaceAll(" ", "::"),
3007
- )
3008
- .join(" "),
3009
- ]
3010
- : []),
3049
+ );
3050
+
3051
+ if (
3052
+ (entry.tags !== undefined && entry.tags.length > 0) ||
3053
+ (additionalTags !== undefined && additionalTags.length > 0)
3054
+ )
3055
+ fields.push(
3056
+ [...(entry.tags ?? []), ...(additionalTags ?? [])]
3057
+ .map((tag: string) => tag.trim().toLowerCase().replaceAll(" ", "::"))
3058
+ .join(" "),
3011
3059
  );
3012
3060
 
3013
3061
  return fields.map((field: string) => field.replaceAll("\n", "<br>"));
@@ -3018,12 +3066,14 @@ export function generateAnkiNote(entry: Result, customData?: string): string[] {
3018
3066
  * @param list An array containing any type of transformed entries ({@link Word}, {@link Kanji}, {@link Radical}, {@link Kana}, {@link Grammar})
3019
3067
  * @param defaultNoteInfo An object with options regarding default values of some note information
3020
3068
  * @param customData An additional string that will be added on the first field of any note type, as a `data-custom` attribute inside an invisible `div`
3069
+ * @param additionalTags Additional tags that will be added alongside the existing entry tags
3021
3070
  * @returns The resulting Anki notes file's content
3022
3071
  */
3023
3072
  export function generateAnkiNotesFile(
3024
3073
  list: readonly Result[],
3025
3074
  defaultNoteInfo?: DefaultNoteInfo,
3026
3075
  customData?: string,
3076
+ additionalTags?: string[],
3027
3077
  ): string {
3028
3078
  const headers: string[] = [noteHeaderKeys.separator, noteHeaderKeys.html];
3029
3079
  let ankiNotes: string = "";
@@ -3141,7 +3191,11 @@ export function generateAnkiNotesFile(
3141
3191
  hasHeader.deckPath = true;
3142
3192
  }
3143
3193
 
3144
- const note: string[] = generateAnkiNote(result, customData);
3194
+ const note: string[] = generateAnkiNote(
3195
+ result,
3196
+ customData,
3197
+ additionalTags,
3198
+ );
3145
3199
 
3146
3200
  if (!hasHeader.tags) {
3147
3201
  headers.push(`${noteHeaderKeys.tags}${note.length + headerCount}`);