Skip to content

Commit

Permalink
v3.4.0
Browse files Browse the repository at this point in the history
  • Loading branch information
hcodes committed Sep 18, 2015
1 parent cf24c79 commit 122310c
Show file tree
Hide file tree
Showing 9 changed files with 162 additions and 117 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.ru.md
@@ -1,5 +1,15 @@
# Changelog

## v3.4.0
Добавлено новое правило «Пробел между числом и словом „год“».

Доработки и исправления в правилах:
- `common/nbsp/afterShortWord`
- `common/nbsp/beforeShortLastWord`
- `ru/nbsp/abbr`
- `ru/nbsp/page`
- `ru/nbsp/m`

## v3.3.0
### Типографирование на лету
```JavaScript
Expand Down
2 changes: 1 addition & 1 deletion bower.json
@@ -1,6 +1,6 @@
{
"name": "typograf",
"version": "3.3.0",
"version": "3.4.0",
"description": "Typograph in JavaScript",
"ignore": [
"**/.*",
Expand Down
53 changes: 39 additions & 14 deletions dist/typograf.js
Expand Up @@ -1031,8 +1031,8 @@ Typograf.rule({
handler: function(text, settings) {
var len = settings.lengthShortWord,
before = ' \u00A0(' + Typograf._privateLabel + Typograf.data('common/quot'),
subStr = '(^|[' + before + '])([' + this.letters() + ']{1,' + len + '})(\\.?) ',
newSubStr = '$1$2$3\u00A0',
subStr = '(^|[' + before + '])([' + this.letters() + ']{1,' + len + '}) ',
newSubStr = '$1$2\u00A0',
re = new RegExp(subStr, 'gim');

return text
Expand All @@ -1050,7 +1050,8 @@ Typograf.rule({
handler: function(text, settings) {
var punc = '.,?!:;',
re = new RegExp('([^' + punc + ']) ([' +
this.letters() + ']{1,' + settings.lengthLastWord + '}[' + punc + '])', 'gi');
this.letters() + ']{1,' + settings.lengthLastWord +
'}[' + punc + '\n])', 'gi');

return text.replace(re, '$1\u00A0$2');
},
Expand Down Expand Up @@ -1542,14 +1543,15 @@ Typograf.rule({
name: 'ru/nbsp/abbr',
index: 565,
handler: function(text) {
return text.replace(/(^|\s)([а-яё]{1,3}\.){2,}(?![а-яё])/g, function($0, $1) {
var abbr = $0.split(/\./);
var re = new RegExp('(^|\\s|' + Typograf._privateLabel + ')(([а-яё]{1,3}\\.){2,})(?![а-яё])', 'g');
return text.replace(re, function($0, $1, $2) {
var abbr = $2.split(/\./);
// Являются ли сокращения ссылкой
if(['рф', 'ру', 'рус', 'орг', 'укр', 'бг', 'срб'].indexOf(abbr[abbr.length - 2]) > -1) {
return $0;
}

return $1 + $0.split(/\./).join('.\u00A0').trim();
return $1 + $2.split(/\./).join('.\u00A0').trim();
});
}
});
Expand Down Expand Up @@ -1620,13 +1622,23 @@ Typograf.rule({
name: 'ru/nbsp/m',
index: 1030,
handler: function(text) {
var m = '(км|м|дм|см|мм)',
re2 = new RegExp('(^|\\D)(\\d+) ?' + m + '2(\\D|$)', 'g'),
re3 = new RegExp('(^|\\D)(\\d+) ?' + m + '3(\\D|$)', 'g');

return text
.replace(re2, '$1$2\u00A0$3²$4')
.replace(re3, '$1$2\u00A0$3³$4');
var label = Typograf._privateLabel,
re = new RegExp('(^|[\\s,.' + label + '])' +
'(\\d+)[ \u00A0]?(мм?|см|км|дм|гм|mm?|km|cm|dm)([23²³])?([\\s.!?,;' +
label + ']|$)', 'gm');

// jshint maxparams:6
return text.replace(re, function($0, $1, $2, $3, $4, $5) {
var pow = {
'2': '²',
'²': '²',
'3': '³',
'³': '³',
'': ''
}[$4 || ''];

return $1 + $2 + '\u00A0' + $3 + pow + ($5 === '\u00A0' ? ' ': $5);
});
}
});

Expand All @@ -1642,7 +1654,10 @@ Typograf.rule({
name: 'ru/nbsp/page',
index: 610,
handler: function(text) {
return text.replace(/ (стр|гл|рис|илл)\./g, '\u00A0$1.');
var re = new RegExp('(^|[)\\s' + Typograf._privateLabel + '])' +
'(стр|гл|рис|илл?|ст|п|c)\\. *(\\d+)([\\s.,?!;:]|$)', 'gim');

return text.replace(re, '$1$2.\u00A0$3$4');
}
});

Expand Down Expand Up @@ -1800,6 +1815,16 @@ Typograf.rule({
}
});

Typograf.rule({
name: 'ru/space/year',
index: 600,
handler: function(text) {
var re = new RegExp('(^| |\u00A0)(\\d{3,4})(год([ауе]|ом)?)([^' +
this.letters() + ']|$)', 'g');
return text.replace(re, '$1$2 $3$5');
}
});

Typograf._sortRules();
Typograf._needSortRules = true;

Expand Down
2 changes: 1 addition & 1 deletion dist/typograf.min.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion dist/typograf.titles.js
Expand Up @@ -210,7 +210,7 @@ Typograf.titles = {
},
"ru/nbsp/m": {
"en": "m2 → м², m3 → м³ and non-breaking space",
"ru": "m2 → м², m3 → м³ и нераз. пробел"
"ru": "м2 → м², м3 → м³ и нераз. пробел"
},
"ru/nbsp/ooo": {
"en": "Non-breaking space after “OOO, ОАО, ЗАО, НИИ, ПБОЮЛ”",
Expand Down Expand Up @@ -258,5 +258,9 @@ Typograf.titles = {
"ru/punctuation/quot": {
"en": "Placement of quotation marks",
"ru": "Расстановка кавычек"
},
"ru/space/year": {
"en": "Space between number and word “год”",
"ru": "Пробел между числом и словом «год»"
}
};
6 changes: 5 additions & 1 deletion dist/typograf.titles.json
Expand Up @@ -210,7 +210,7 @@
},
"ru/nbsp/m": {
"en": "m2 → м², m3 → м³ and non-breaking space",
"ru": "m2 → м², m3 → м³ и нераз. пробел"
"ru": "м2 → м², м3 → м³ и нераз. пробел"
},
"ru/nbsp/ooo": {
"en": "Non-breaking space after “OOO, ОАО, ЗАО, НИИ, ПБОЮЛ”",
Expand Down Expand Up @@ -258,5 +258,9 @@
"ru/punctuation/quot": {
"en": "Placement of quotation marks",
"ru": "Расстановка кавычек"
},
"ru/space/year": {
"en": "Space between number and word “год”",
"ru": "Пробел между числом и словом «год»"
}
}
99 changes: 50 additions & 49 deletions docs/RULES.en.md
Expand Up @@ -3,15 +3,15 @@
|| Name ▼ | Title | [Index](./RULES_SORTED.en.md) | Queue | On |
|--:|--------|-------|------------------------------:|:-----:|:--:|
| 1. | [common/other/delBOM](../src/rules/common/other/delBOM.js) | Delete character BOM (Byte Order Mark) | 0 | start ||
| 2. | [common/nbsp/nowrap](../src/rules/common/nbsp/nowrap.js) | Replace non-breaking space to normal space in tags nowrap and nobr | 100 | start ||
| 3. | [common/html/nbr](../src/rules/common/html/nbr.js) | Replacement line break on <br/> | 110 | start | |
| 4. | [common/sym/copy](../src/rules/common/sym/copy.js) | (c) → ©, (tm) → ™, (r) → ® | 10 | | |
| 5. | [ru/punctuation/hellip](../src/rules/ru/punctuation/hellip.js) | Three points on ellipsis | 20 | ||
| 6. | [ru/dash/to](../src/rules/ru/dash/to.js) | Hyphen before “то, либо, нибудь” | 30 | ||
| 7. | [ru/dash/kade](../src/rules/ru/dash/kade.js) | Hyphen before “ка, де, кась| 31 | ||
| 8. | [ru/dash/izza](../src/rules/ru/dash/izza.js) | Hyphen between “из-за| 33 | ||
| 9. | [ru/dash/izpod](../src/rules/ru/dash/izpod.js) | Hyphen between “из-под| 35 | ||
| 10. | [common/nbsp/replaceNbsp](../src/rules/common/nbsp/replaceNbsp.js) | Replacing non-breaking space in the ordinary | 0 | utf ||
| 2. | [common/nbsp/replaceNbsp](../src/rules/common/nbsp/replaceNbsp.js) | Replacing non-breaking space in the ordinary | 0 | utf ||
| 3. | [common/nbsp/nowrap](../src/rules/common/nbsp/nowrap.js) | Replace non-breaking space to normal space in tags nowrap and nobr | 100 | start | |
| 4. | [common/html/nbr](../src/rules/common/html/nbr.js) | Replacement line break on <br/> | 110 | start | |
| 5. | [common/sym/copy](../src/rules/common/sym/copy.js) | (c) → ©, (tm) → ™, (r) → ® | 10 | ||
| 6. | [ru/punctuation/hellip](../src/rules/ru/punctuation/hellip.js) | Three points on ellipsis | 20 | ||
| 7. | [ru/dash/to](../src/rules/ru/dash/to.js) | Hyphen before “то, либо, нибудь| 30 | ||
| 8. | [ru/dash/kade](../src/rules/ru/dash/kade.js) | Hyphen before “ка, де, кась| 31 | ||
| 9. | [ru/dash/izza](../src/rules/ru/dash/izza.js) | Hyphen between “из-за| 33 | ||
| 10. | [ru/dash/izpod](../src/rules/ru/dash/izpod.js) | Hyphen between “из-под” | 35 | ||
| 11. | [ru/dash/koe](../src/rules/ru/dash/koe.js) | Hyphen after “кое” and “кой” | 38 | ||
| 12. | [ru/dash/taki](../src/rules/ru/dash/taki.js) | Hyphen between “верно-таки” and etc. | 39 | ||
| 13. | [common/space/delLeadingBlanks](../src/rules/common/space/delLeadingBlanks.js) | Remove spaces at start of line | 504 | | |
Expand All @@ -27,46 +27,47 @@
| 23. | [ru/nbsp/abbr](../src/rules/ru/nbsp/abbr.js) | Non-breaking space in abbreviations, e.g. “т. д.” | 565 | ||
| 24. | [common/punctuation/delDoublePunctuation](../src/rules/common/punctuation/delDoublePunctuation.js) | Removing double punctuation | 580 | ||
| 25. | [common/nbsp/afterShortWord](../src/rules/common/nbsp/afterShortWord.js) | Non-breaking space after short word | 590 | ||
| 26. | [common/space/delBeforePercent](../src/rules/common/space/delBeforePercent.js) | Remove space before %, ‰ and ‱ | 600 | ||
| 26. | [ru/nbsp/beforeParticle](../src/rules/ru/nbsp/beforeParticle.js) | Non-breaking space before “ли, ль, же, бы, б” | 600 | ||
| 27. | [ru/dash/weekday](../src/rules/ru/dash/weekday.js) | Dash between the days of the week | 600 | ||
| 28. | [ru/nbsp/beforeParticle](../src/rules/ru/nbsp/beforeParticle.js) | Non-breaking space before “ли, ль, же, бы, б| 600 | ||
| 29. | [ru/nbsp/afterNumberSign](../src/rules/ru/nbsp/afterNumberSign.js) | Non-breaking space after № | 610 | ||
| 28. | [ru/space/year](../src/rules/ru/space/year.js) | Space between number and word “год| 600 | ||
| 29. | [common/space/delBeforePercent](../src/rules/common/space/delBeforePercent.js) | Remove space before %, ‰ and ‱ | 600 | ||
| 30. | [ru/dash/month](../src/rules/ru/dash/month.js) | Dash between months | 610 | ||
| 31. | [ru/nbsp/page](../src/rules/ru/nbsp/page.js) | Non-breaking space before “стр., гл., рис., илл.” | 610 | ||
| 32. | [common/nbsp/afterPara](../src/rules/common/nbsp/afterPara.js) | Non-breaking space after § | 610 | ||
| 33. | [common/nbsp/afterNumber](../src/rules/common/nbsp/afterNumber.js) | Non-breaking space between number and word | 615 | ||
| 34. | [ru/dash/main](../src/rules/ru/dash/main.js) | Replacement hyphen with dash | 620 | ||
| 35. | [common/nbsp/beforeShortLastWord](../src/rules/common/nbsp/beforeShortLastWord.js) | Non-breaking space before last short word in sentence | 620 | ||
| 36. | [en/punctuation/quot](../src/rules/en/punctuation/quot.js) | Placement of quotation marks | 700 | ||
| 37. | [ru/punctuation/quot](../src/rules/ru/punctuation/quot.js) | Placement of quotation marks | 700 | ||
| 38. | [ru/optalign/quot](../src/rules/ru/optalign/quot.js) | for opening quotation marks | 1000 | | |
| 39. | [ru/optalign/bracket](../src/rules/ru/optalign/bracket.js) | for opening bracket | 1001 | | |
| 40. | [ru/optalign/comma](../src/rules/ru/optalign/comma.js) | for comma | 1002 | | |
| 41. | [common/number/mathSigns](../src/rules/common/number/mathSigns.js) | != → ≠, <= → ≤, >= → ≥, ~= → ≅, +- → ± | 1010 | | |
| 42. | [common/sym/cf](../src/rules/common/sym/cf.js) | Adding ° to C and F | 1020 | ||
| 43. | [ru/nbsp/m](../src/rules/ru/nbsp/m.js) | m2 → м², m3 → м³ and non-breaking space | 1030 | ||
| 44. | [common/number/times](../src/rules/common/number/times.js) | x× (10 x 5 → 10×5) | 1050 | ||
| 45. | [ru/nbsp/xxxx](../src/rules/ru/nbsp/xxxx.js) | Non-breaking space before XXXX г. (2012 г.) | 1060 | ||
| 46. | [ru/nbsp/yy](../src/rules/ru/nbsp/yy.js) | г.г. → гг. and non-breaking space | 1080 | ||
| 47. | [ru/nbsp/cc](../src/rules/ru/nbsp/cc.js) | Remove spaces and extra points in centuries | 1090 | ||
| 48. | [ru/nbsp/ooo](../src/rules/ru/nbsp/ooo.js) | Non-breaking space after “OOO, ОАО, ЗАО, НИИ, ПБОЮЛ” | 1100 | ||
| 49. | [ru/nbsp/dayMonth](../src/rules/ru/nbsp/dayMonth.js) | Non-breaking space between number and month | 1105 | ||
| 50. | [ru/punctuation/ano](../src/rules/ru/punctuation/ano.js) | Placement of commas before “а” and “но” | 1110 | ||
| 51. | [ru/nbsp/addr](../src/rules/ru/nbsp/addr.js) | Placement of non-breaking space after “г.”, “обл.”, “ул.”, “пр.”, “кв.” et al. | 1115 | ||
| 52. | [common/number/fraction](../src/rules/common/number/fraction.js) | 1/2 → ½, 1/4 → ¼, 3/3 → ¾ | 1120 | ||
| 53. | [common/sym/arrow](../src/rules/common/sym/arrow.js) | ->→, <- | 1130 | ||
| 54. | [ru/money/euro](../src/rules/ru/money/euro.js) | €100100 € | 1140 | ||
| 55. | [ru/money/dollar](../src/rules/ru/money/dollar.js) | $100 → 100 $ | 1140 | ||
| 56. | [common/punctuation/exclamationQuestion](../src/rules/common/punctuation/exclamationQuestion.js) | !??! | 1140 | ||
| 57. | [ru/money/ruble](../src/rules/ru/money/ruble.js) | 1 руб. → 1 ₽ | 1145 | | |
| 58. | [common/nbsp/dpi](../src/rules/common/nbsp/dpi.js) | Non-breaking space before lpi, dpi | 1150 | | |
| 59. | [common/punctuation/exclamation](../src/rules/common/punctuation/exclamation.js) | !! → ! | 1150 | ||
| 60. | [common/other/repeatWord](../src/rules/common/other/repeatWord.js) | Removing repeat words | 1200 | | |
| 61. | [ru/number/ordinals](../src/rules/ru/number/ordinals.js) | N-ый, -ой, -ая, -ое, -ые, -ым, -ом, -ых → N-й, -я, -е, -м, -х (25-й) | 1300 | | |
| 31. | [common/nbsp/afterPara](../src/rules/common/nbsp/afterPara.js) | Non-breaking space after § | 610 | ||
| 32. | [ru/nbsp/page](../src/rules/ru/nbsp/page.js) | Non-breaking space before “стр., гл., рис., илл.” | 610 | ||
| 33. | [ru/nbsp/afterNumberSign](../src/rules/ru/nbsp/afterNumberSign.js) | Non-breaking space after № | 610 | ||
| 34. | [common/nbsp/afterNumber](../src/rules/common/nbsp/afterNumber.js) | Non-breaking space between number and word | 615 | ||
| 35. | [ru/dash/main](../src/rules/ru/dash/main.js) | Replacement hyphen with dash | 620 | ||
| 36. | [common/nbsp/beforeShortLastWord](../src/rules/common/nbsp/beforeShortLastWord.js) | Non-breaking space before last short word in sentence | 620 | ||
| 37. | [en/punctuation/quot](../src/rules/en/punctuation/quot.js) | Placement of quotation marks | 700 | ||
| 38. | [ru/punctuation/quot](../src/rules/ru/punctuation/quot.js) | Placement of quotation marks | 700 | | |
| 39. | [ru/optalign/quot](../src/rules/ru/optalign/quot.js) | for opening quotation marks | 1000 | | |
| 40. | [ru/optalign/bracket](../src/rules/ru/optalign/bracket.js) | for opening bracket | 1001 | | |
| 41. | [ru/optalign/comma](../src/rules/ru/optalign/comma.js) | for comma | 1002 | | |
| 42. | [common/number/mathSigns](../src/rules/common/number/mathSigns.js) | != → ≠, <= → ≤, >= → ≥, ~= → ≅, +- → ± | 1010 | ||
| 43. | [common/sym/cf](../src/rules/common/sym/cf.js) | Adding ° to C and F | 1020 | ||
| 44. | [ru/nbsp/m](../src/rules/ru/nbsp/m.js) | m2м², m3 → м³ and non-breaking space | 1030 | ||
| 45. | [common/number/times](../src/rules/common/number/times.js) | x → × (10 x 5 → 10×5) | 1050 | ||
| 46. | [ru/nbsp/xxxx](../src/rules/ru/nbsp/xxxx.js) | Non-breaking space before XXXX г. (2012 г.) | 1060 | ||
| 47. | [ru/nbsp/yy](../src/rules/ru/nbsp/yy.js) | г.г. → гг. and non-breaking space | 1080 | ||
| 48. | [ru/nbsp/cc](../src/rules/ru/nbsp/cc.js) | Remove spaces and extra points in centuries | 1090 | ||
| 49. | [ru/nbsp/ooo](../src/rules/ru/nbsp/ooo.js) | Non-breaking space after “OOO, ОАО, ЗАО, НИИ, ПБОЮЛ” | 1100 | ||
| 50. | [ru/nbsp/dayMonth](../src/rules/ru/nbsp/dayMonth.js) | Non-breaking space between number and month | 1105 | ||
| 51. | [ru/punctuation/ano](../src/rules/ru/punctuation/ano.js) | Placement of commas before “а” and “но” | 1110 | ||
| 52. | [ru/nbsp/addr](../src/rules/ru/nbsp/addr.js) | Placement of non-breaking space after “г.”, “обл.”, “ул.”, “пр.”, “кв.” et al. | 1115 | ||
| 53. | [common/number/fraction](../src/rules/common/number/fraction.js) | 1/2½, 1/4 → ¼, 3/3¾ | 1120 | ||
| 54. | [common/sym/arrow](../src/rules/common/sym/arrow.js) | ->→, <- → ← | 1130 | ||
| 55. | [ru/money/euro](../src/rules/ru/money/euro.js) | 100 → 100 | 1140 | ||
| 56. | [ru/money/dollar](../src/rules/ru/money/dollar.js) | $100100 $ | 1140 | ||
| 57. | [common/punctuation/exclamationQuestion](../src/rules/common/punctuation/exclamationQuestion.js) | !? → ?! | 1140 | | |
| 58. | [ru/money/ruble](../src/rules/ru/money/ruble.js) | 1 руб. → 1 ₽ | 1145 | | |
| 59. | [common/nbsp/dpi](../src/rules/common/nbsp/dpi.js) | Non-breaking space before lpi, dpi | 1150 | ||
| 60. | [common/punctuation/exclamation](../src/rules/common/punctuation/exclamation.js) | !! → ! | 1150 | | |
| 61. | [common/other/repeatWord](../src/rules/common/other/repeatWord.js) | Removing repeat words | 1200 | | |
| 62. | [ru/date/main](../src/rules/ru/date/main.js) | Converting dates YYYY-MM-DD type DD.MM.YYYY | 1300 | ||
| 63. | [ru/date/weekday](../src/rules/ru/date/weekday.js) | 2 Мая, Понедельник → 2 мая, понедельник | 1310 | ||
| 64. | [common/html/mail](../src/rules/common/html/mail.js) | Placement of links for e-mail | 2000 | | |
| 65. | [common/html/url](../src/rules/common/html/url.js) | Placement of links | 2010 | | |
| 66. | [common/html/pbr](../src/rules/common/html/pbr.js) | Placement of p and br tags | 90 | end | |
| 67. | [common/html/stripTags](../src/rules/common/html/stripTags.js) | Removing HTML-tags | 100 | end | |
| 68. | [common/html/escape](../src/rules/common/html/escape.js) | Escaping HTML | 110 | end | |
| 63. | [ru/number/ordinals](../src/rules/ru/number/ordinals.js) | N-ый, -ой, -ая, -ое, -ые, -ым, -ом, -ых → N-й, -я, -е, -м, -х (25-й) | 1300 | ||
| 64. | [ru/date/weekday](../src/rules/ru/date/weekday.js) | 2 Мая, Понедельник → 2 мая, понедельник | 1310 | ||
| 65. | [common/html/mail](../src/rules/common/html/mail.js) | Placement of links for e-mail | 2000 | | |
| 66. | [common/html/url](../src/rules/common/html/url.js) | Placement of links | 2010 | | |
| 67. | [common/html/pbr](../src/rules/common/html/pbr.js) | Placement of p and br tags | 90 | end | |
| 68. | [common/html/stripTags](../src/rules/common/html/stripTags.js) | Removing HTML-tags | 100 | end | |
| 69. | [common/html/escape](../src/rules/common/html/escape.js) | Escaping HTML | 110 | end | |

0 comments on commit 122310c

Please sign in to comment.