diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..aa366b7 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +!.gitignore +composer.lock +vendor diff --git a/README.md b/README.md index 3a51211..66887dc 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ -# unmarkdown +# unmarkdorn +Library for escaping all markdown symbols + +```php +// Library for escaping all markdown symbols +use mirzaev\unmarkdown\unmarkdown; + +var_dump(unmarkdown('*Hello!*')); // "\\*Hello\\!\\*" +``` + +## Installation +```bash +composer require mirzaev/unmarkdown +``` + -Escaping all markdown symbols \ No newline at end of file diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..727a418 --- /dev/null +++ b/composer.json @@ -0,0 +1,36 @@ +{ + "name": "mirzaev/unmarkdown", + "description": "Library for escaping all markdown symbols", + "homepage": "https://git.svoboda.works/mirzaev/unmarkdown", + "type": "library", + "keywords": [ + "markdown", + "escaping" + ], + "readme": "README.md", + "license": "WTFPL", + "authors": [ + { + "name": "Arsen Mirzaev Tatyano-Muradovich", + "email": "arsen@mirzaev.sexy", + "homepage": "https://mirzaev.sexy", + "role": "Creator" + } + ], + "support": { + "issues": "https://git.svoboda.works/mirzaev/unmarkdown/issues" + }, + "require": { + "php": "^8.4" + }, + "autoload": { + "psr-4": { + "mirzaev\\unmarkdown\\": "mirzaev/unmarkdown/system" + } + }, + "autoload-dev": { + "psr-4": { + "mirzaev\\unmarkdown\\tests\\": "mirzaev/unmarkdown/tests" + } + } +} diff --git a/mirzaev/unmarkdown/system/unmarkdown.php b/mirzaev/unmarkdown/system/unmarkdown.php new file mode 100644 index 0000000..249ffcb --- /dev/null +++ b/mirzaev/unmarkdown/system/unmarkdown.php @@ -0,0 +1,49 @@ +', + '<', + '!', + '`', + '\\', + '|', + '+' + ], + $exceptions + ); + + // Initializing the registry of escaped characters + $to = []; + foreach ($from as $symbol) $to[] = "\\$symbol"; + + // Escaping the text and exit (success) + return str_replace($from, $to, $text); + }