• 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/link-list.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 a link list markdown section.
10
 */
11
class Link_List implements Section_Interface {
12

13
        /**
14
         * The type of the links.
15
         *
16
         * @var string
17
         */
18
        private $type;
19

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

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

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

41
        /**
42
         * Adds a link to the list.
43
         *
44
         * @param Link $link The link to add.
45
         *
46
         * @return void
47
         */
NEW
48
        public function add_link( Link $link ): void {
×
NEW
49
                $this->links[] = $link;
×
50
        }
51

52
        /**
53
         * Returns the prefix of the link list section.
54
         *
55
         * @return string
56
         */
NEW
57
        public function get_prefix(): string {
×
NEW
58
                return '## ';
×
59
        }
60

61
        /**
62
         * Renders the link item.
63
         *
64
         * @return string
65
         */
NEW
66
        public function render(): string {
×
NEW
67
                if ( empty( $this->links ) ) {
×
NEW
68
                        return '';
×
69
                }
70

NEW
71
                $rendered_links = [];
×
NEW
72
                foreach ( $this->links as $link ) {
×
NEW
73
                        $rendered_links[] = '- ' . $link->render();
×
74
                }
75

NEW
76
                return $this->type . \PHP_EOL . \implode( \PHP_EOL, $rendered_links );
×
77
        }
78

79
        /**
80
         * Escapes the markdown content.
81
         *
82
         * @param Markdown_Escaper $markdown_escaper The markdown escaper.
83
         *
84
         * @return void
85
         */
NEW
86
        public function escape_markdown( Markdown_Escaper $markdown_escaper ): void {
×
NEW
87
                $this->type = $markdown_escaper->escape_markdown_content( $this->type );
×
88

NEW
89
                foreach ( $this->links as $link ) {
×
NEW
90
                        $link->escape_markdown( $markdown_escaper );
×
91
                }
92
        }
93
}
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