You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
724 B
32 lines
724 B
<?php
|
|
|
|
namespace App\Parser\DocxParser;
|
|
|
|
use App\Parser\DocxParser\Traits\Helper;
|
|
|
|
class PreserveText
|
|
{
|
|
|
|
use Helper;
|
|
|
|
public function handle($element)
|
|
{
|
|
$text = $element->getText();
|
|
if (is_array($text)) {
|
|
$text = implode(' ', $text);
|
|
}
|
|
|
|
return [
|
|
'content' => [
|
|
'content' => preg_replace("/\{[^)]+\}/", '{REF_NUMBER}', $text, 1),
|
|
'type' => 'text'
|
|
],
|
|
'type' => 'preserveText',
|
|
'index' => $element->getElementIndex(),
|
|
'children' => [],
|
|
'styleName' => 'Level2Number',
|
|
'styleDepth' => 1,
|
|
'depth' => 0
|
|
];
|
|
}
|
|
}
|