Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/Processors/TextProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ class TextProcessor
private const PLACEHOLDER_PREFIX = '__PH2T__';
private const PLACEHOLDER_SUFFIX = '__';

private string $nbsp;

public function __construct(
private Config $config,
private DataContainer $data,
) {
$this->nbsp = (string) html_entity_decode(' ', \ENT_QUOTES | \ENT_HTML5, 'UTF-8');
}

public function process(string $text): void
Expand Down Expand Up @@ -142,10 +145,9 @@ private function normalizePlainText(string $text): string

$text = str_replace(["\u{200E}", "\u{200F}"], '', $text);

$nbsp = html_entity_decode(' ', \ENT_QUOTES | \ENT_HTML5, 'UTF-8');
if ('' !== $nbsp) {
if ('' !== $this->nbsp) {
$placeholder = Constants::UNIFIABLE['nbsp'];
$text = str_replace($nbsp, $placeholder, $text);
$text = str_replace($this->nbsp, $placeholder, $text);
}

return $text;
Expand Down
Loading