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

Yoast / wordpress-seo / 481faf637ba3a7c1e5f2bfef59b582ac39523de6

21 May 2025 09:11AM UTC coverage: 46.174%. First build
481faf637ba3a7c1e5f2bfef59b582ac39523de6

Pull #22291

github

web-flow
Merge pull request #22278 from Yoast/577-sanitize-and-deal-with-special-markdown-characters-before-writing-to-file

577 sanitize and deal with special markdown characters before writing to file
Pull Request #22291: Introduce the llms.txt feature

52 of 403 new or added lines in 30 files covered. (12.9%)

15586 of 33755 relevant lines covered (46.17%)

3.67 hits per line

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

0.0
/src/llms-txt/domain/markdown/sections/intro.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.MaxExceeded
3
namespace Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections;
4

5
use Yoast\WP\SEO\Llms_Txt\Application\Markdown_Escaper;
6
use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Items\Link;
7

8
/**
9
 * Represents the intro section.
10
 */
11
class Intro implements Section_Interface {
12

13
        /**
14
         * The intro content.
15
         *
16
         * @var string
17
         */
18
        private $intro_content;
19

20
        /**
21
         * The intro links.
22
         *
23
         * @var Link[]
24
         */
25
        private $intro_links = [];
26

27
        /**
28
         * Class constructor.
29
         *
30
         * @param string $intro_content The intro content.
31
         * @param Link[] $intro_links   The intro links.
32
         */
NEW
33
        public function __construct( string $intro_content, array $intro_links ) {
×
NEW
34
                $this->intro_content = $intro_content;
×
35

NEW
36
                foreach ( $intro_links as $link ) {
×
NEW
37
                        $this->add_link( $link );
×
38
                }
39
        }
40

41
        /**
42
         * Returns the prefix of the intro section.
43
         *
44
         * @return string
45
         */
NEW
46
        public function get_prefix(): string {
×
NEW
47
                return '';
×
48
        }
49

50
        /**
51
         * Adds a link to the intro section.
52
         *
53
         * @param Link $link The link to add.
54
         *
55
         * @return void
56
         */
NEW
57
        public function add_link( Link $link ): void {
×
NEW
58
                $this->intro_links[] = $link;
×
59
        }
60

61
        /**
62
         * Returns the content of the intro section.
63
         *
64
         * @return string
65
         */
NEW
66
        public function render(): string {
×
NEW
67
                if ( \count( $this->intro_links ) === 0 ) {
×
NEW
68
                        return $this->intro_content;
×
69
                }
70

NEW
71
                $rendered_links = \array_map(
×
NEW
72
                        static function ( $link ) {
×
NEW
73
                                return $link->render();
×
NEW
74
                        },
×
NEW
75
                        $this->intro_links
×
NEW
76
                );
×
77

NEW
78
                $this->intro_content = \sprintf(
×
NEW
79
                        $this->intro_content,
×
NEW
80
                        ...$rendered_links
×
NEW
81
                );
×
NEW
82
                return $this->intro_content;
×
83
        }
84

85
        /**
86
         * Escapes the markdown content.
87
         *
88
         * @param Markdown_Escaper $markdown_escaper The markdown escaper.
89
         *
90
         * @return void
91
         */
NEW
92
        public function escape_markdown( Markdown_Escaper $markdown_escaper ): void {
×
NEW
93
                foreach ( $this->intro_links as $link ) {
×
NEW
94
                        $link->escape_markdown( $markdown_escaper );
×
95
                }
96
        }
97
}
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

© 2025 Coveralls, Inc