@vojtaholik/static-kit-core 2.1.2 → 2.1.3

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/vlna.ts +14 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vojtaholik/static-kit-core",
3
- "version": "2.1.2",
3
+ "version": "2.1.3",
4
4
  "type": "module",
5
5
  "exports": {
6
6
  ".": {
package/src/vlna.ts CHANGED
@@ -23,11 +23,21 @@
23
23
  const SINGLE_CHAR_RE = /(?<=\s|^)([ksvzouaiKSVZOUAI]) /g;
24
24
 
25
25
  /**
26
- * Replace space after single-char Czech prepositions/conjunctions with \u00A0.
26
+ * Short (2–3 char) Czech prepositions that shouldn't end a line.
27
+ * Case-insensitive match at word boundary.
28
+ */
29
+ const SHORT_PREP_RE =
30
+ /(?<=\s|^)(bez|nad|pod|pro|při|přes|před|mezi|jako|ani|ale|nebo|Bez|Nad|Pod|Pro|Při|Přes|Před|Mezi|Jako|Ani|Ale|Nebo|BEZ|NAD|POD|PRO|PŘI|PŘES|PŘED|MEZI|JAKO|ANI|ALE|NEBO|do|ke|ku|na|od|po|se|ve|za|ze|Do|Ke|Ku|Na|Od|Po|Se|Ve|Za|Ze|DO|KE|KU|NA|OD|PO|SE|VE|ZA|ZE) /g;
31
+
32
+ /**
33
+ * Replace space after Czech prepositions/conjunctions with \u00A0.
34
+ * Handles single-char (k, s, v…) and short words (bez, nad, pro…).
27
35
  * Plain text only — no HTML awareness.
28
36
  */
29
37
  export function vlna(text: string): string {
30
- return text.replace(SINGLE_CHAR_RE, "$1\u00A0");
38
+ return text
39
+ .replace(SINGLE_CHAR_RE, "$1\u00A0")
40
+ .replace(SHORT_PREP_RE, "$1\u00A0");
31
41
  }
32
42
 
33
43
  /**
@@ -49,6 +59,7 @@ const SKIP_TAGS = new Set([
49
59
  "kbd",
50
60
  "var",
51
61
  "samp",
62
+ "title",
52
63
  ]);
53
64
 
54
65
  /**
@@ -101,7 +112,7 @@ export function vlnaHtml(html: string): string {
101
112
  if (inSkipTag) {
102
113
  result += text;
103
114
  } else {
104
- result += vlna(text);
115
+ result += preventWidow(vlna(text));
105
116
  }
106
117
 
107
118
  i = textEnd;