diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d3c27ad..48ae522 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -20,6 +20,7 @@ jobs: - 8.1 - 8.2 - 8.3 + - 8.4 steps: - name: Checkout diff --git a/CHANGELOG.md b/CHANGELOG.md index c299a54..0e3010b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog -## [Unreleased](https://github.com/akhx/typograf/compare/v0.6.0...HEAD) +## [Unreleased](https://github.com/akhx/typograf/compare/v0.7.0...HEAD) + +## [0.7.0](https://github.com/akhx/typograf/compare/v0.6.0...v0.7.0) - 2024-12-08 * url добавлен в safeBlock +* новое правило для работы с адресами ## [0.6.0](https://github.com/akhx/typograf/compare/v0.5.0...v0.6.0) - 2024-09-25 * переработан SafeBlock diff --git a/docs/RULES.md b/docs/RULES.md index 82ca1fb..837b97d 100644 --- a/docs/RULES.md +++ b/docs/RULES.md @@ -1,6 +1,6 @@ ## Nbsp | Класс | Название | Сортировка | Активность | Параметры | -| --- | --- | --- | --- | --- | +| --- | --- | -- | --- | --- | | [Nbsp\ReplaceNbsp](../src/Rule/Nbsp/ReplaceNbsp.php) | Замена неразрывного пробела на обычный перед типографированием | -100 | выкл | | | [Nbsp\AfterNumber](../src/Rule/Nbsp/AfterNumber.php) | Неразрывной пробел, после чисел | 500 | вкл | maxLen = 5 | | [Nbsp\AfterShortWord](../src/Rule/Nbsp/AfterShortWord.php) | Неразрывной пробел, после короткого слова | 500 | вкл | len = 2 | @@ -8,6 +8,7 @@ | [Nbsp\DayMonth](../src/Rule/Nbsp/DayMonth.php) | Нераз. пробел между числом и месяцем | 500 | вкл | | | [Nbsp\BeforeParticle](../src/Rule/Nbsp/BeforeParticle.php) | Нераз. пробел перед «ли», «ль», «же», «бы», «б» | 510 | вкл | | | [Nbsp\Initials](../src/Rule/Nbsp/Initials.php) | Неразрывной пробел инициалов и фамилии | 500 | вкл | | +| [Nbsp\Address](../src/Rule/Nbsp/Address.php) | Неразрывной пробел, а адресах г. ул. кв. | 450 | вкл | | ## Dash | Класс | Название | Сортировка | Активность | Параметры | | --- | --- | --- | --- | --- | diff --git a/src/Rule/Nbsp/Address.php b/src/Rule/Nbsp/Address.php new file mode 100644 index 0000000..acca0cb --- /dev/null +++ b/src/Rule/Nbsp/Address.php @@ -0,0 +1,27 @@ +)(обл|кр|ст|пос|с|д|ул|пер|пр|пр-т|просп|пл|бул|б-р|наб|ш|туп|оф|комн?|уч|вл|влад|стр|кор|г|эт|мкр|влд)\.\s+(\S)#iu', + '#(^|\s|>)(дом|корпус|этаж)\s+(\S)#iu', + ]; + + $replace = [ + '$1$2.' . $this->char['nbsp'] . '$3', + '$1$2' . $this->char['nbsp'] . '$3', + ]; + + return preg_replace($pattern, $replace, $text); + } +} diff --git a/tests/Rule/Nbsp/AddressTest.php b/tests/Rule/Nbsp/AddressTest.php new file mode 100644 index 0000000..c6d83d5 --- /dev/null +++ b/tests/Rule/Nbsp/AddressTest.php @@ -0,0 +1,59 @@ +
"Пример"
+Наш адрес: Россия, г. Саратов, ул. Антонова, дом 25, кв. 72.
https://www.domain.com/path/test-05-09-2024/ https://domain.com/path/test-05-09-2024/ [embed]https://domain.com/path/test-05-09-2024/[/embed] @@ -184,6 +185,7 @@ public function testApplyDocument(): void«Пример»
+Наш адрес: Россия, г. Саратов, ул. Антонова, дом 25, кв. 72.
https://www.domain.com/path/test-05-09-2024/ https://domain.com/path/test-05-09-2024/ [embed]https://domain.com/path/test-05-09-2024/[/embed]