Merge branch 'issue-19' of krzysiej/paper-pi into master
This commit was merged in pull request #20.
This commit is contained in:
@@ -21,6 +21,23 @@ class HtmlToPos
|
|||||||
*/
|
*/
|
||||||
$posText = preg_replace('/^\s*[!#].*?$[\r\n]?/m', '', $posText);
|
$posText = preg_replace('/^\s*[!#].*?$[\r\n]?/m', '', $posText);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* poniższy kod wybieraz tekstu fragmenty w podwójnych nawiasach kwadratowych, rozdziela je po przecinkach
|
||||||
|
* następnie losuje element i podmienia go w miejsce oryginalnego fragmentu
|
||||||
|
*/
|
||||||
|
$re = "#\[\[(.*?)\]\]#s";
|
||||||
|
preg_match_all($re, $posText, $found, PREG_SET_ORDER, 0);
|
||||||
|
foreach ($found as $elements) {
|
||||||
|
$data = explode(',', $elements[1]);
|
||||||
|
$data = array_filter($data, function ($el) {
|
||||||
|
return strlen(trim($el));
|
||||||
|
});
|
||||||
|
$data = array_values($data);
|
||||||
|
$pos = strpos($posText, $elements[0]);
|
||||||
|
$posText = substr_replace($posText, $data[mt_rand(0, count($data) - 1)], $pos, strlen($elements[0]));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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
|
||||||
|
|||||||
@@ -65,11 +65,9 @@ class Paper
|
|||||||
public function sendPrint($title, $text = '', $image = false, $imageLocal = true)
|
public function sendPrint($title, $text = '', $image = false, $imageLocal = true)
|
||||||
{
|
{
|
||||||
$this->sendImagePrint($image, $imageLocal);
|
$this->sendImagePrint($image, $imageLocal);
|
||||||
|
|
||||||
$this->sendHeaderPrint($title);
|
$this->sendHeaderPrint($title);
|
||||||
$htmlToPos = new HtmlToPos();
|
$htmlToPos = new HtmlToPos();
|
||||||
$this->printer->text($htmlToPos->convert($text));
|
$this->printer->text($htmlToPos->convert($text));
|
||||||
|
|
||||||
$this->printer->feed(3);
|
$this->printer->feed(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user