@videinfra/static-website-builder 1.15.8 → 1.15.10

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/CHANGELOG.md CHANGED
@@ -4,6 +4,12 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
5
5
  and this project adheres to [Semantic Versioning](http://semver.org/).
6
6
 
7
+ ## [1.15.10] - 2025-09-26
8
+ - Updated "preposition_nbsp" TWIG filter
9
+
10
+ ## [1.15.9] - 2025-09-10
11
+ - Added dashes to the "preposition_nbsp" TWIG filter
12
+
7
13
  ## [1.15.7] - 2025-07-31
8
14
  ### Added
9
15
  - Optional chaining to the JS
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@videinfra/static-website-builder",
3
- "version": "1.15.8",
3
+ "version": "1.15.10",
4
4
  "description": "Customizable static site project builder",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -1,8 +1,9 @@
1
1
  const prepositions = [
2
2
  'about', 'above', 'across', 'after', 'against', 'along', 'amid', 'among', 'around', 'as', 'at', 'before', 'behind', 'below', 'beneath', 'beside', 'besides', 'between', 'beyond', 'by', 'concerning', 'despite', 'down', 'during', 'except', 'for', 'from', 'in', 'inside', 'into', 'like', 'near', 'of', 'off', 'on', 'onto', 'out', 'outside', 'over', 'past', 'regarding', 'round', 'since', 'through', 'throughout', 'to', 'toward', 'towards', 'under', 'underneath', 'until', 'unto', 'up', 'upon', 'with', 'within', 'without', 'a', 'an', 'the',
3
- 'в', 'на', 'по', 'к', 'у', 'от', 'из', 'с', 'над', 'под', 'при', 'без', 'до', 'для', 'за', 'через', 'перед', 'около', 'вокруг', 'о', 'об', 'обо', 'про', 'среди', 'между', 'ради', 'вдоль', 'вне', 'кроме', 'сквозь', 'вследствие', 'благодаря', 'согласно', 'вопреки', 'вроде', 'насчёт', 'касательно', 'против', 'со', 'во', 'ко', 'ото', 'изо', 'надо', 'подо', 'передо', 'передо', 'и'
3
+ 'в', 'на', 'по', 'к', 'у', 'от', 'из', 'с', 'над', 'под', 'при', 'без', 'до', 'для', 'за', 'через', 'перед', 'около', 'вокруг', 'о', 'об', 'обо', 'про', 'среди', 'между', 'ради', 'вдоль', 'вне', 'кроме', 'сквозь', 'вследствие', 'благодаря', 'согласно', 'вопреки', 'вроде', 'насчёт', 'касательно', 'со', 'против', 'во', 'ко', 'ото', 'изо', 'надо', 'подо', 'передо', 'передо', 'из-за', 'чтобы', 'когда', 'его', 'которое', 'как', 'и', 'ей', 'они', 'мы', 'или', 'всё', 'я', 'которое', 'вашей', 'эти', 'что', 'вам', 'не уверены', 'а', 'вы', 'этим', 'вашим', 'все', 'если', 'о которой', 'в этом', 'но', 'которые', 'же', 'ваш', 'этой'
4
4
  ];
5
5
 
6
+
6
7
  // Word boundary regex
7
8
  // (?<= # Lookbehind, but don't consume
8
9
  // (^| # Start of string or
@@ -10,6 +11,19 @@ const prepositions = [
10
11
  const regexWordBoundary = '(?<=(^|[^\\p{L}]))';
11
12
  const regexEscape = /[.*+?^${}()|[\]\\]/g;
12
13
 
14
+ const regexMdash = /\s+—/uig;
15
+ const regexNdash = /\s+–/uig;
16
+ const regexHyphen = /\s+-/uig; // actual hyphen from keyboard
17
+ const regexHyphen2 = /\s+‐/uig;
18
+ const regexFigureDash = /\s+‒/uig;
19
+
20
+ const regexMdashEntity = /\s+&mdash;/uig;
21
+ const regexNdashEntity = /\s+&ndash;/uig;
22
+ const regexHyphenEntity = /\s+&#45;/uig;
23
+ const regexHyphen2Entity = /\s+&hyphen;/uig;
24
+ const regexFigureDashEntity = /\s+&#x2012;/uig;
25
+ const regexDashEntity = /\s+&dash;/uig;
26
+
13
27
  let prepositionsRegex = null;
14
28
 
15
29
  function escapeRegExp(string) {
@@ -22,7 +36,22 @@ function prepositionNbsp(text) {
22
36
  prepositionsRegex = new RegExp(`${regexWordBoundary}(${prepositionsEscaped.join('|')})\\s+`, 'uig');
23
37
  }
24
38
 
25
- return text.replace(prepositionsRegex, '$2&nbsp;');
39
+ text = text.replace(prepositionsRegex, '$2&nbsp;');
40
+
41
+ text = text.replace(regexMdash, '&nbsp;&mdash;', text);
42
+ text = text.replace(regexNdash, '&nbsp;&ndash;', text);
43
+ text = text.replace(regexHyphen, '&nbsp;&#45;', text);
44
+ text = text.replace(regexHyphen2, '&nbsp;&hyphen;', text);
45
+ text = text.replace(regexFigureDash, '&nbsp;&#x2012;', text);
46
+
47
+ text = text.replace(regexMdashEntity, '&nbsp;&mdash;', text);
48
+ text = text.replace(regexNdashEntity, '&nbsp;&ndash;', text);
49
+ text = text.replace(regexHyphenEntity, '&nbsp;&#45;', text);
50
+ text = text.replace(regexHyphen2Entity, '&nbsp;&hyphen;', text);
51
+ text = text.replace(regexFigureDashEntity, '&nbsp;&#x2012;', text);
52
+ text = text.replace(regexDashEntity, '&nbsp;&dash;', text);
53
+
54
+ return text;
26
55
  }
27
56
 
28
57
  module.exports = prepositionNbsp;
@@ -21,6 +21,21 @@ test('preposition_nbsp russian', () => {
21
21
  expect(preposition_nbsp('ппппп before над дддд')).toEqual('ппппп before&nbsp;над&nbsp;дддд');
22
22
  });
23
23
 
24
+ test('preposition_nbsp hyphens', () => {
25
+ expect(preposition_nbsp('hello — world')).toEqual('hello&nbsp;&mdash; world');
26
+ expect(preposition_nbsp('hello – world')).toEqual('hello&nbsp;&ndash; world');
27
+ expect(preposition_nbsp('hello - world')).toEqual('hello&nbsp;&#45; world');
28
+ expect(preposition_nbsp('hello ‐ world')).toEqual('hello&nbsp;&hyphen; world');
29
+ expect(preposition_nbsp('hello ‒ world')).toEqual('hello&nbsp;&#x2012; world');
30
+ expect(preposition_nbsp('hello &dash; world')).toEqual('hello&nbsp;&dash; world');
31
+
32
+ // Don't replace hyphens with entities if not needed
33
+ expect(preposition_nbsp('hello— world')).toEqual('hello— world');
34
+
35
+ // Hyphens + prepositions
36
+ expect(preposition_nbsp('hello ‒ at world')).toEqual('hello&nbsp;&#x2012; at&nbsp;world');
37
+ });
38
+
24
39
  test('Preposition TWIG filter applied', () => {
25
40
  return fsPromises.readFile(path.resolve(publicPath, 'preposition.html'), {'encoding': 'utf8'}).then((html) => {
26
41
  expect(html).toBe('<html><body>hello at&nbsp;world</body></html>');