From a509783d7f10af0d4bfb3d720460bc3d5ae6b7b2 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 7 Jul 2024 14:55:41 +0400 Subject: [PATCH 1/4] + You can turn off typography for a text fragment aslo by using the `` tag. --- README.md | 6 ++++-- README_ru.md | 6 ++++-- src/Snippet.php | 8 +++++++- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 87b4759..c86fdec 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,8 @@ Snippet for text typography. The snippet doesn’t use third-party services, also it sends no requests. In other words, everything is performed on your server. +You can turn off typography for a text fragment using the `` or `` tags. + ## Requires @@ -152,11 +154,11 @@ require_once( ``` -### Turn off typography for a text fragment (the `` tag) +### Turn off typography for a text fragment (the `` or `` tags) ```html [[ddTypograph? - &text=`Some text. The snippet will not change this text inside the tag. It's easy.` + &text=`Some text. The snippet will not change this text inside the tag. It's easy. Additionally, `span` with the single `notg` class is also supported.` ]] ``` diff --git a/README_ru.md b/README_ru.md index 99b4b08..6132f6b 100644 --- a/README_ru.md +++ b/README_ru.md @@ -3,6 +3,8 @@ Сниппет типографирует текст. Не использует сторонних сервисов, не отправляет никаких запросов, всё делается прямо у вас на сервере. +Вы можете отключить типографирование какого-то фрагмента текста с помощью тегов `` или ``. + ## Использует @@ -152,11 +154,11 @@ require_once( ``` -### Отключить работу типографа для фрагмента текста (тег ``) +### Отключить работу типографа для фрагмента текста (теги `` или ``) ```html [[ddTypograph? - &text=`Какой-то текст. Текст внутри этого тега не будет типографироваться. Вот так просто.` + &text=`Какой-то текст. Текст внутри этого тега не будет типографироваться. Вот так просто. Кроме того, поддерживается также `span` с единственным классом `notg`.` ]] ``` diff --git a/src/Snippet.php b/src/Snippet.php index e134aa8..3ff00aa 100644 --- a/src/Snippet.php +++ b/src/Snippet.php @@ -54,7 +54,7 @@ protected function prepareParams($params = []){ /** * run - * @version 1.2 (2023-08-23) + * @version 1.3 (2024-07-07) * * @return {string} */ @@ -79,6 +79,12 @@ public function run(){ '

 

', $result ); + //Support of (just replace to ) + $result = preg_replace( + '/(.+?)<\/span>/is', + '$1', + $result + ); if (!isset($ddTypograph)){ $ddTypograph = new \EMTypograph(); From c5abeb01acc18014d3eeb29b8c905aae9719762f Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 7 Jul 2024 14:57:26 +0400 Subject: [PATCH 2/4] * README, CHANGELOG: Misprints have been fixed. --- CHANGELOG.md | 2 +- README.md | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fc720d6..a818180 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,7 +19,7 @@ * \* Attention! PHP >= 5.6 is required. * \* Attention! (MODX)EvolutionCMS.libraries.ddTools >= 0.48.1 is required. * \+ You can just call `\DDTools\Snippet::runSnippet` to run the snippet without DB and eval (see README → Examples). -* \+ `\ddDomainComparator\Snippet`: The new class. All snippet code was moved here. +* \+ `\ddTypograph\Snippet`: The new class. All snippet code was moved here. * \+ README → Links. * \* Composer.json: * \+ `homepage` diff --git a/README.md b/README.md index c86fdec..4b308c2 100644 --- a/README.md +++ b/README.md @@ -59,19 +59,19 @@ require_once( ## Parameters description * `text` - * Desctription: Text to correct. + * Description: Text to correct. * Valid values: `string` * **Required** * `optAlign` - * Desctription: Optical alignment (hanging punctuation). + * Description: Optical alignment (hanging punctuation). * Valid values: * `0` * `1` * Default value: `0` * `optAlign_useClasses` - * Desctription: Use CSS classes instead of inline styles for optical alignment (`` instead of ``). + * Description: Use CSS classes instead of inline styles for optical alignment (`` instead of ``). If the parameter is enabled, don't forget to specify the following CSS rules on your site: ```css .oa_obracket_sp_s {margin-right:0.3em;} @@ -89,28 +89,28 @@ require_once( * Default value: `0` * `text_paragraphs` - * Desctription: Section signs and line breaks insertion. + * Description: Section signs and line breaks insertion. * Valid values: * `0` * `1` * Default value: `0` * `text_autoLinks` - * Desctription: Marking links (including email ones). + * Description: Marking links (including email ones). * Valid values: * `0` * `1` * Default value: `0` * `etc_unicodeConvert` - * Desctription: Convert HTML entities into Unicode (`—` instead of `—`, etc). + * Description: Convert HTML entities into Unicode (`—` instead of `—`, etc). * Valid values: * `0` * `1` * Default value: `1` * `noTags` - * Desctription: Whether HTML element insertion is allowed or not. + * Description: Whether HTML element insertion is allowed or not. There are cases when using tags causes the text to be invalid, for example, using the snippet inside of an HTML attribute. * Valid values: * `0` @@ -118,7 +118,7 @@ require_once( * Default value: `0` * `excludeTags` - * Desctription: HTML tags which content will be ignored by snippet. + * Description: HTML tags which content will be ignored by snippet. * Valid values: `stringCommaSeparated` * Default value: `'notg,code'` From cde5c1bfedb35314295abd886d258db9b9d9e4c5 Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 7 Jul 2024 15:03:28 +0400 Subject: [PATCH 3/4] + `\ddTypograph\Snippet::$theEMT`: The new private static property. - The global variable `$ddTypograph` is not used anymore. --- src/Snippet.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Snippet.php b/src/Snippet.php index 3ff00aa..01e5ee1 100644 --- a/src/Snippet.php +++ b/src/Snippet.php @@ -34,6 +34,8 @@ class Snippet extends \DDTools\Snippet { ] ; + private static $theEMT = null; + /** * prepareParams * @version 1.0 (2021-03-29) @@ -54,7 +56,7 @@ protected function prepareParams($params = []){ /** * run - * @version 1.3 (2024-07-07) + * @version 1.3.1 (2024-07-07) * * @return {string} */ @@ -64,8 +66,6 @@ public function run(){ //Если есть что типографировать if (strlen($result) > 4){ - global $ddTypograph; - //Заменим кавычки, вставленные через спец. символы на обычные (а то не обрабатываются в библиотеке) $result = str_replace( '"', @@ -86,8 +86,8 @@ public function run(){ $result ); - if (!isset($ddTypograph)){ - $ddTypograph = new \EMTypograph(); + if (is_null(static::$theEMT)){ + static::$theEMT = new \EMTypograph(); } //Safe tags @@ -155,7 +155,7 @@ public function run(){ 'off' ; - $ddTypograph->setup([ + static::$theEMT->setup([ //Расстановка «кавычек-елочек» первого уровня 'Quote.quotes' => 'on', //Внутренние кавычки-лапки @@ -330,10 +330,10 @@ public function run(){ 'Etc.split_number_to_triads' => 'on' ]); - $ddTypograph->set_text($result); + static::$theEMT->set_text($result); //Типографируем - $result = $ddTypograph->apply(); + $result = static::$theEMT->apply(); //Clean back empty lines $result = str_replace( From 2c2fc4f27a160ff841db794835ba2abfa5cafb7f Mon Sep 17 00:00:00 2001 From: Ilyas Ronef Date: Sun, 7 Jul 2024 15:16:19 +0400 Subject: [PATCH 4/4] Prerelease --- CHANGELOG.md | 4 ++++ CHANGELOG_ru.md | 4 ++++ README.md | 2 +- README_ru.md | 2 +- composer.json | 2 +- ddTypograph_snippet.php | 4 ++-- src/Snippet.php | 2 +- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a818180..1be9a53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # (MODX)EvolutionCMS.snippets.ddTypograph changelog +## Version 2.7 (2024-07-07) +* \+ You can turn off typography for a text fragment aslo by using the `` tag. + + ## Version 2.6.1 (2023-08-23) * \* TinyMCE empty lines (`

 

`) are no longer modified. diff --git a/CHANGELOG_ru.md b/CHANGELOG_ru.md index 09f89bc..6759562 100644 --- a/CHANGELOG_ru.md +++ b/CHANGELOG_ru.md @@ -1,6 +1,10 @@ # (MODX)EvolutionCMS.snippets.ddTypograph changelog +## Версия 2.7 (2024-07-07) +* \+ Вы можете отключить типографирование какого-то фрагмента текста также с помощью тега ``. + + ## Версия 2.6.1 (2023-08-23) * \* Пустые строки TinyMCE (`

 

`) больше не изменяются. diff --git a/README.md b/README.md index 4b308c2..ac8e6bc 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ require_once( #### 1. Elements → Snippets: Create a new snippet with the following data 1. Snippet name: `ddTypograph`. -2. Description: `2.6.1 Snippet for text typography. The snippet doesn’t use third-party services, also it sends no requests. In other words, everything is performed on your server.`. +2. Description: `2.7 Snippet for text typography. The snippet doesn’t use third-party services, also it sends no requests. In other words, everything is performed on your server.`. 3. Category: `Core`. 4. Parse DocBlock: `no`. 5. Snippet code (php): Insert content of the `ddTypograph_snippet.php` file from the archive. diff --git a/README_ru.md b/README_ru.md index 6132f6b..a9f9ea5 100644 --- a/README_ru.md +++ b/README_ru.md @@ -44,7 +44,7 @@ require_once( #### 1. Элементы → Сниппеты: Создайте новый сниппет со следующими параметрами 1. Название сниппета: `ddTypograph`. -2. Описание: `2.6.1 Сниппет типографирует текст. Не использует сторонних сервисов, не отправляет никаких запросов, всё делается прямо у вас на сервере.`. +2. Описание: `2.7 Сниппет типографирует текст. Не использует сторонних сервисов, не отправляет никаких запросов, всё делается прямо у вас на сервере.`. 3. Категория: `Core`. 4. Анализировать DocBlock: `no`. 5. Код сниппета (php): Вставьте содержимое файла `ddTypograph_snippet.php` из архива. diff --git a/composer.json b/composer.json index e16339c..6179dc6 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "dd/evolutioncms-snippets-ddtypograph", "type": "modxevo-snippet", - "version": "2.6.1", + "version": "2.7.0", "description": "Snippet for text typography. The snippet doesn't use third-party services, also it sends no requests. In other words, everything is performed on your server.", "keywords": [ "modx", diff --git a/ddTypograph_snippet.php b/ddTypograph_snippet.php index 1e45995..adb83ee 100644 --- a/ddTypograph_snippet.php +++ b/ddTypograph_snippet.php @@ -1,13 +1,13 @@