• 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/llms-txt-renderer.php
1
<?php
2
// phpcs:disable Yoast.NamingConventions.NamespaceName.TooLong
3
namespace Yoast\WP\SEO\Llms_Txt\Domain\Markdown;
4

5
use Yoast\WP\SEO\Llms_Txt\Domain\Markdown\Sections\Section_Interface;
6

7
/**
8
 * The renderer of the LLMs.txt file.
9
 */
10
class Llms_Txt_Renderer {
11

12
        /**
13
         * The sections.
14
         *
15
         * @var Section_Interface[]
16
         */
17
        private $sections;
18

19
        /**
20
         * Adds a section.
21
         *
22
         * @param Section_Interface $section The section to add.
23
         *
24
         * @return void
25
         */
NEW
26
        public function add_section( Section_Interface $section ): void {
×
NEW
27
                $this->sections[] = $section;
×
28
        }
29

30
        /**
31
         * Returns the sections.
32
         *
33
         * @return Section_Interface[]
34
         */
NEW
35
        public function get_sections(): array {
×
NEW
36
                return $this->sections;
×
37
        }
38

39
        /**
40
         * Renders the items of the bucket.
41
         *
42
         * @return string
43
         */
NEW
44
        public function render(): string {
×
NEW
45
                if ( empty( $this->sections ) ) {
×
NEW
46
                        return '';
×
47
                }
48

NEW
49
                $rendered_sections = [];
×
NEW
50
                foreach ( $this->sections as $section ) {
×
NEW
51
                        $section_content = $section->render();
×
NEW
52
                        if ( $section_content === '' ) {
×
NEW
53
                                continue;
×
54
                        }
55

NEW
56
                        $rendered_sections[] = $section->get_prefix() . $section_content . \PHP_EOL;
×
57
                }
58

NEW
59
                return \implode( \PHP_EOL, $rendered_sections );
×
60
        }
61
}
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