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

dg / texy / 12879605443

21 Jan 2025 03:31AM UTC coverage: 92.224% (+0.03%) from 92.197%
12879605443

push

github

dg
regexp: uses unmatched as null (BC break)

14 of 14 new or added lines in 6 files covered. (100.0%)

101 existing lines in 14 files now uncovered.

2372 of 2572 relevant lines covered (92.22%)

0.92 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

14

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

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

36

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

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

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

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

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

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

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

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

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

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