• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Yoast / Yoast-SEO-for-TYPO3 / 13327579701

14 Feb 2025 10:43AM UTC coverage: 1.276%. First build
13327579701

push

github

web-flow
Merge pull request #597 from Yoast/feature/v11

[FEATURE] Release 11.0.0

21 of 894 new or added lines in 76 files covered. (2.35%)

35 of 2744 relevant lines covered (1.28%)

0.04 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/Classes/Service/Preview/ContentExtractors/BodyProcessor.php
1
<?php
2

3
declare(strict_types=1);
4

5
namespace YoastSeoForTypo3\YoastSeo\Service\Preview\ContentExtractors;
6

7
class BodyProcessor implements BodyProcessorInterface
8
{
9
    public function getBody(string $content): string
10
    {
NEW
11
        $body = '';
×
12

NEW
13
        $bodyFound = preg_match("/<body[^>]*>(.*)<\/body>/is", $content, $matchesBody);
×
14

NEW
15
        if ($bodyFound) {
×
NEW
16
            $body = $matchesBody[1];
×
17

NEW
18
            preg_match_all(
×
NEW
19
                '/<!--\s*?TYPO3SEARCH_begin\s*?-->.*?<!--\s*?TYPO3SEARCH_end\s*?-->/mis',
×
NEW
20
                $body,
×
NEW
21
                $indexableContents
×
NEW
22
            );
×
23

NEW
24
            if (is_array($indexableContents[0]) && !empty($indexableContents[0])) {
×
NEW
25
                $body = implode('', $indexableContents[0]);
×
26
            }
27
        }
28

NEW
29
        return $this->prepareBody($body);
×
30
    }
31

32
    protected function prepareBody(string $body): string
33
    {
NEW
34
        $body = $this->stripTagsContent($body, '<script><noscript>');
×
NEW
35
        $body = preg_replace(['/\s?\n\s?/', '/\s{2,}/'], [' ', ' '], $body);
×
NEW
36
        $body = strip_tags((string)$body, '<h1><h2><h3><h4><h5><p><a><img>');
×
37

NEW
38
        return trim($body);
×
39
    }
40

41
    protected function stripTagsContent(string $text, string $tags = ''): string
42
    {
NEW
43
        preg_match_all('/<(.+?)[\s]*\/?[\s]*>/si', trim($tags), $foundTags);
×
NEW
44
        $tagsArray = array_unique($foundTags[1]);
×
45

NEW
46
        if (count($tagsArray) > 0) {
×
NEW
47
            return (string)preg_replace('@<(' . implode('|', $tagsArray) . ')\b.*?>.*?</\1>@si', '', $text);
×
48
        }
49

NEW
50
        return $text;
×
51
    }
52
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc