typograf 7.4.0 → 7.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ # v7.4.2
4
+ - Исправлена расстановка кавычек рядом с троеточием #452.
5
+ - Обновлены dev-зависимости в package.json.
6
+
7
+ # v7.4.1
8
+ Откат #447 из-за js-ошибки SyntaxError: Invalid regular expression: invalid group specifier name.
9
+
3
10
  # v7.4.0
4
11
  - Исправлена некорректная вставка запятой между `ну`, `а` и `но` #447 @denis-bosiy
5
12
  - Обновлены dev-зависимости в package.json.
package/README.md CHANGED
@@ -5,7 +5,6 @@
5
5
  [![NPM version](https://img.shields.io/npm/v/typograf.svg?style=flat)](https://www.npmjs.com/package/typograf)
6
6
  [![NPM downloads](https://img.shields.io/npm/dm/typograf.svg?style=flat)](https://www.npmjs.com/package/typograf)
7
7
  [![Coverage Status](https://img.shields.io/coveralls/typograf/typograf.svg?style=flat)](https://coveralls.io/r/typograf/typograf)
8
- [![bundlephobia](https://badgen.net/bundlephobia/minzip/typograf)](https://bundlephobia.com/result?p=typograf)
9
8
  [![install size](https://packagephobia.com/badge?p=typograf)](https://packagephobia.com/result?p=typograf)
10
9
 
11
10
  Помогает автоматически расставить неразрывные пробелы, исправить мелкие опечатки, привести кавычки к правильному виду, заменить дефисы на тире в нужных местах и многое другое.
@@ -39,6 +38,7 @@
39
38
  - [TinyMCE](https://habrahabr.ru/post/266337/)
40
39
  - [Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=rusnasonov.vscode-typograf)
41
40
  - [Bitrix](https://github.com/ilimurzin/bitrix-typograf)
41
+ - [Markdown-it-typograf](https://github.com/ceigh/markdown-it-typograf)
42
42
  - [Поддерживаемые правила](./docs/RULES.ru.md)
43
43
  - API
44
44
  - [Включить или отключить правила](./docs/api_rules.md)
@@ -1,4 +1,4 @@
1
- /*! typograf | © 2024 Denis Seleznev | MIT License | https://github.com/typograf/typograf */
1
+ /*! typograf | © 2025 Denis Seleznev | MIT License | https://github.com/typograf/typograf */
2
2
  (function (global, factory) {
3
3
  typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4
4
  typeof define === 'function' && define.amd ? define(factory) :
@@ -19,7 +19,7 @@
19
19
  OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
20
20
  PERFORMANCE OF THIS SOFTWARE.
21
21
  ***************************************************************************** */
22
- /* global Reflect, Promise, SuppressedError, Symbol */
22
+ /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
23
23
 
24
24
 
25
25
  var __assign = function() {
@@ -806,7 +806,7 @@
806
806
  return preparedRule;
807
807
  }
808
808
 
809
- var PACKAGE_VERSION = '7.4.0';
809
+ var PACKAGE_VERSION = '7.4.2';
810
810
 
811
811
  function prepareHtmlEntity(htmlEntity) {
812
812
  var result = {
@@ -887,8 +887,12 @@
887
887
  _this.rulesByQueues[rule.queue] = _this.rulesByQueues[rule.queue] || [];
888
888
  _this.rulesByQueues[rule.queue].push(rule);
889
889
  });
890
- this.prefs.disableRule && this.disableRule(this.prefs.disableRule);
891
- this.prefs.enableRule && this.enableRule(this.prefs.enableRule);
890
+ if (this.prefs.disableRule) {
891
+ this.disableRule(this.prefs.disableRule);
892
+ }
893
+ if (this.prefs.enableRule) {
894
+ this.enableRule(this.prefs.enableRule);
895
+ }
892
896
  }
893
897
  Typograf.addRule = function (rule) {
894
898
  addRule(rule);
@@ -1073,12 +1077,16 @@
1073
1077
  if (queue === void 0) { queue = DEFAULT_QUEUE_NAME; }
1074
1078
  var rules = this.rulesByQueues[queue];
1075
1079
  var innerRules = this.innerRulesByQueues[queue];
1076
- innerRules && innerRules.forEach(function (rule) {
1077
- _this.ruleIterator(context, rule);
1078
- });
1079
- rules && rules.forEach(function (rule) {
1080
- _this.ruleIterator(context, rule);
1081
- });
1080
+ if (innerRules) {
1081
+ innerRules.forEach(function (rule) {
1082
+ _this.ruleIterator(context, rule);
1083
+ });
1084
+ }
1085
+ if (rules) {
1086
+ rules.forEach(function (rule) {
1087
+ _this.ruleIterator(context, rule);
1088
+ });
1089
+ }
1082
1090
  };
1083
1091
  Typograf.prototype.ruleIterator = function (context, rule) {
1084
1092
  if ((context.prefs.live === true && rule.live === false) || (context.prefs.live === false && rule.live === true)) {
@@ -1088,9 +1096,13 @@
1088
1096
  if (context.prefs.ruleFilter && !context.prefs.ruleFilter(rule)) {
1089
1097
  return;
1090
1098
  }
1091
- this.onBeforeRule && this.onBeforeRule(rule.name, context);
1099
+ if (this.onBeforeRule) {
1100
+ this.onBeforeRule(rule.name, context);
1101
+ }
1092
1102
  context.text = rule.handler.call(this, context.text, this.settings[rule.name], context);
1093
- this.onAfterRule && this.onAfterRule(rule.name, context);
1103
+ if (this.onAfterRule) {
1104
+ this.onAfterRule(rule.name, context);
1105
+ }
1094
1106
  }
1095
1107
  };
1096
1108
  Typograf.prototype.prepareRuleSettings = function (rule) {
@@ -1983,7 +1995,7 @@
1983
1995
  }
1984
1996
  if (prev === privateLabel) {
1985
1997
  var hasRight = _this.afterRight.indexOf(next) > -1;
1986
- var prevInfo = params.safeTags.getPrevTagInfo(params.context, text, pos - 1);
1998
+ var prevInfo = params.safeTags.getPrevTagInfo(params.context, text, pos + 1);
1987
1999
  if (hasRight && prevInfo && prevInfo.group === 'html') {
1988
2000
  return prev + (prevInfo.isClosing ? rquote : lquote) + next;
1989
2001
  }
@@ -3170,15 +3182,8 @@
3170
3182
  var anoRule = {
3171
3183
  name: 'ru/punctuation/ano',
3172
3184
  handler: function (text) {
3173
- var parts = [
3174
- '([^«„[(!?,:;\\-‒–—\\s' + privateLabel + '])', // Запятую не ставим, если уже есть какой-либо знак
3175
- '(?<!([^а-яА-Я]+ну|Ну))', // Запятую не ставим перед ну
3176
- '(\\s+)', // Отступ между левой и правой частями в виде пробельных символов
3177
- '(а|но)', // Союзы
3178
- '(?= |\u00A0|\\n)' // Остальная часть предложения(пробел, неразрывной пробел, перевод строки)
3179
- ];
3180
- var re = new RegExp(parts.join(''), 'g');
3181
- return text.replace(re, '$1,$3$4');
3185
+ var re = new RegExp('([^«„[(!?,:;\\-‒–—\\s' + privateLabel + '])(\\s+)(а|но)(?= |\u00A0|\\n)', 'g');
3186
+ return text.replace(re, '$1,$2$3');
3182
3187
  },
3183
3188
  };
3184
3189