just formatted
This commit is contained in:
@@ -13,37 +13,37 @@ namespace mirzaev;
|
|||||||
* @return string Escaped text
|
* @return string Escaped text
|
||||||
*/
|
*/
|
||||||
function unmarkdown(string $text, array $exceptions = []): string
|
function unmarkdown(string $text, array $exceptions = []): string
|
||||||
{
|
{
|
||||||
// Initializing the registry of characters for escaping
|
// Initializing the registry of characters for escaping
|
||||||
$from = array_diff(
|
$from = array_diff(
|
||||||
[
|
[
|
||||||
'.',
|
'.',
|
||||||
'#',
|
'#',
|
||||||
'*',
|
'*',
|
||||||
'-',
|
'-',
|
||||||
'_',
|
'_',
|
||||||
'=',
|
'=',
|
||||||
'[',
|
'[',
|
||||||
']',
|
']',
|
||||||
'{',
|
'{',
|
||||||
'}',
|
'}',
|
||||||
'(',
|
'(',
|
||||||
')',
|
')',
|
||||||
'>',
|
'>',
|
||||||
'<',
|
'<',
|
||||||
'!',
|
'!',
|
||||||
'`',
|
'`',
|
||||||
'\\\\',
|
'\\\\',
|
||||||
'|',
|
'|',
|
||||||
'+'
|
'+'
|
||||||
],
|
],
|
||||||
$exceptions
|
$exceptions
|
||||||
);
|
);
|
||||||
|
|
||||||
// Initializing the registry of escaped characters
|
// Initializing the registry of escaped characters
|
||||||
$to = [];
|
$to = [];
|
||||||
foreach ($from as $symbol) $to[] = "\\$symbol";
|
foreach ($from as $symbol) $to[] = "\\$symbol";
|
||||||
|
|
||||||
// Escaping the text and exit (success)
|
// Escaping the text and exit (success)
|
||||||
return str_replace($from, $to, $text);
|
return str_replace($from, $to, $text);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user