Removes before printing lines with ! or # as a leading characer even after some space characters in front.

This commit is contained in:
kplaczek
2018-04-19 22:59:47 +02:00
parent b68bf4b2e1
commit 2a242ff7ed

View File

@@ -15,6 +15,12 @@ class HtmlToPos
public function convert($html = '') public function convert($html = '')
{ {
$posText = $this->handleNewLine($html); $posText = $this->handleNewLine($html);
/**
* usuwa linijki które na początku mają ! albo #
*/
$posText = preg_replace('/^\s*[!#].*?$[\r\n]/m', '', $posText);
/** /**
* przeszukiwanie tekstu pod katem zawartości [ liczba, liczba2 ] i zamienianiu tego na randomową liczbę z przedziału * przeszukiwanie tekstu pod katem zawartości [ liczba, liczba2 ] i zamienianiu tego na randomową liczbę z przedziału
* liczba - liczba2 * liczba - liczba2
@@ -24,8 +30,9 @@ class HtmlToPos
preg_match_all($re, $html, $matches, PREG_SET_ORDER, 0); preg_match_all($re, $html, $matches, PREG_SET_ORDER, 0);
foreach ($matches as $match) { foreach ($matches as $match) {
$pos = strpos($posText, $match[0]); $pos = strpos($posText, $match[0]);
$posText = substr_replace($posText, rand($match[1], $match[2]), $pos, strlen($match[0])); $posText = substr_replace($posText, mb_rand($match[1], $match[2]), $pos, strlen($match[0]));
} }
return $posText; return $posText;
} }