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

dg / texy / 16790351274

06 Aug 2025 10:42PM UTC coverage: 92.746% (+0.005%) from 92.741%
16790351274

push

github

dg
HtmlElement: removed toHtml() & toText()

18 of 19 new or added lines in 5 files covered. (94.74%)

136 existing lines in 23 files now uncovered.

2391 of 2578 relevant lines covered (92.75%)

0.93 hits per line

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

96.3
/src/Texy/Modules/BlockQuoteModule.php
1
<?php
2

3
/**
4
 * This file is part of the Texy! (https://texy.info)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
declare(strict_types=1);
9

10
namespace Texy\Modules;
11

12
use Texy;
13
use function max, strlen;
14

15

16
/**
17
 * Blockquote module.
18
 */
19
final class BlockQuoteModule extends Texy\Module
20
{
21
        public function __construct(Texy\Texy $texy)
1✔
22
        {
23
                $this->texy = $texy;
1✔
24

25
                $texy->registerBlockPattern(
1✔
26
                        $this->parse(...),
1✔
27
                        '~^
28
                                (?: ' . Texy\Patterns::MODIFIER_H . '\n)? # modifier (1)
1✔
29
                                >                                      # blockquote char
30
                                ( [ \t]++ | : )                        # space/tab or colon (2)
31
                                ( \S.*+ )                              # content (3)
32
                        $~mU',
33
                        'blockquote',
1✔
34
                );
35
        }
1✔
36

37

38
        /**
39
         * Callback for:.
40
         *
41
         * > They went in single file, running like hounds on a strong scent,
42
         * and an eager light was in their eyes. Nearly due west the broad
43
         * swath of the marching Orcs tramped its ugly slot; the sweet grass
44
         * of Rohan had been bruised and blackened as they passed.
45
         * >:http://www.mycom.com/tolkien/twotowers.html
46
         */
47
        public function parse(Texy\BlockParser $parser, array $matches): Texy\HtmlElement|string|null
1✔
48
        {
49
                [, $mMod, $mPrefix, $mContent] = $matches;
1✔
50
                // [1] => .(title)[class]{style}<>
51
                // [2] => spaces |
52
                // [3] => ... / LINK
53

54
                $texy = $this->texy;
1✔
55

56
                $el = new Texy\HtmlElement('blockquote');
1✔
57
                $mod = new Texy\Modifier($mMod);
1✔
58
                $mod->decorate($texy, $el);
1✔
59

60
                $content = '';
1✔
61
                $spaces = '';
1✔
62
                do {
63
                        if ($spaces === '') {
1✔
64
                                $spaces = max(1, strlen($mPrefix));
1✔
65
                        }
66
                        $content .= $mContent . "\n";
1✔
67

68
                        if (!$parser->next("~^>(?: | ([ \\t]{1,$spaces} | :) (.*))$~mA", $matches)) {
1✔
69
                                break;
1✔
70
                        }
71

72
                        [, $mPrefix, $mContent] = $matches;
1✔
73
                } while (true);
1✔
74

75
                $el->inject($texy->parseBlock($content, $parser->isIndented()));
1✔
76

77
                // no content?
78
                if (!$el->count()) {
1✔
UNCOV
79
                        return null;
×
80
                }
81

82
                // event listener
83
                $texy->invokeHandlers('afterBlockquote', [$parser, $el, $mod]);
1✔
84

85
                return $el;
1✔
86
        }
87
}
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