mirror of
https://tildegit.org/sbgodin/HtmGem.git
synced 2023-08-25 13:53:12 +02:00
Replaces preg_replace by mb_ereg_replace
* No more use of separators. * \$1 becomes \\1
This commit is contained in:
parent
011f38c36f
commit
e723f268fc
@ -18,4 +18,8 @@ With Nginx, you can use:
|
||||
rewrite ^(.+\.gmi)$ /htmgem.php?url=$1 last;
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
php-mbstring is required
|
||||
|
||||
So the page is available at [http://thesite/htmgem.php/directory/page.gmi].
|
||||
|
@ -47,14 +47,13 @@ EOL);
|
||||
* @param &$text where to replace.
|
||||
*/
|
||||
function markupPreg($instruction, $markup, &$text) {
|
||||
#return preg_replace("#{$instruction}((?!{$instruction}.)+)(?:{$instruction})?#", "<{$markup}>$1</{$markup}>", $text);
|
||||
$output = $text;
|
||||
|
||||
# Replaces couples "__word__" into "<i>word</i>".
|
||||
$output = preg_replace("#${instruction}(.+?)${instruction}#", "<{$markup}>$1</{$markup}>", $output);
|
||||
$output = mb_ereg_replace("${instruction}(.+?)${instruction}", "<{$markup}>\\1</{$markup}>", $output);
|
||||
|
||||
# Replaces a remaining __ into "<i>…</i>" to the end of the line.
|
||||
$output = preg_replace("#${instruction}(.+)?#", "<{$markup}>$1</{$markup}>", $output);
|
||||
$output = mb_ereg_replace("${instruction}(.+)?", "<{$markup}>\\1</{$markup}>", $output);
|
||||
|
||||
$text = $output;
|
||||
}
|
||||
@ -77,7 +76,8 @@ function addTextAttributes(&$line) {
|
||||
*/
|
||||
function htmlEscape(&$text) {
|
||||
$text = htmlspecialchars($text, ENT_HTML5, "UTF-8", false);
|
||||
$text = preg_replace("#\ ([?!;])#", " \$1", $text); # Espace fine insécable
|
||||
$text = mb_ereg_replace("\ ([?!:;»€$])", " \\1", $text); # Espace fine insécable
|
||||
$text = mb_ereg_replace("([«])\ ", "\\1 ", $text); # Espace fine insécable
|
||||
}
|
||||
|
||||
$mode = null;
|
||||
|
Loading…
Reference in New Issue
Block a user