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

dg / texy / 29746802114

20 Jul 2026 01:19PM UTC coverage: 94.677% (+0.04%) from 94.641%
29746802114

push

github

dg
Dead code removed

- Engine::getPatternNames() and Texy::getEngine(): no callers in src or tests.
- LinkDefinitionModule::resolveUrl(): unreachable. Both bracket forms it
  handles ([*img*] and [ref]) are already consumed by earlier returns in
  resolveLinkNodeUrl(), so it could only ever return its argument unchanged.
- Text\Renderer: CodeBlockNode type 'comment' never exists; comments are a
  separate CommentNode. Leftover from before the node split.

1 of 1 new or added line in 1 file covered. (100.0%)

74 existing lines in 15 files now uncovered.

3344 of 3532 relevant lines covered (94.68%)

0.95 hits per line

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

96.77
/src/Texy/Modules/BlockQuoteModule.php
1
<?php declare(strict_types=1);
2

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

8
namespace Texy\Modules;
9

10
use Texy;
11
use Texy\Nodes\BlockQuoteNode;
12
use Texy\ParseContext;
13
use Texy\Range;
14
use Texy\Syntax;
15
use function max, strlen;
16

17

18
/**
19
 * Processes blockquote syntax with nested content.
20
 */
21
final class BlockQuoteModule extends Texy\Module
22
{
23
        public function __construct(
1✔
24
                private Texy\Texy $texy,
25
        ) {
26
        }
1✔
27

28

29
        public function beforeParse(string &$text): void
1✔
30
        {
31
                $this->texy->registerBlockPattern(
1✔
32
                        $this->parse(...),
1✔
33
                        '~^
34
                                (?: ' . Texy\Patterns::ModifierHAlign . '\n)? # modifier (1)
1✔
35
                                >                                      # blockquote char
36
                                ( [ \t]++ | : )                        # space/tab or colon (2)
37
                                ( \S.*+ )                              # content (3)
38
                        $~mUx',
39
                        Syntax::Blockquote,
1✔
40
                );
41
        }
1✔
42

43

44
        /**
45
         * Parses blockquote.
46
         * @param  array{string, ?string, string, string}  $matches
47
         * @param  array{int, ?int, int, int}  $offsets
48
         */
49
        public function parse(ParseContext $context, array $matches, array $offsets): ?BlockQuoteNode
1✔
50
        {
51
                [, $mMod, $mPrefix, $mContent] = $matches;
1✔
52

53
                $startOffset = $offsets[0];
1✔
54
                $totalLength = strlen($matches[0]);
1✔
55

56
                // Collect lines with their absolute offsets
57
                $lines = [['content' => $mContent, 'offset' => $offsets[3]]];
1✔
58
                $spaces = max(1, strlen($mPrefix));
1✔
59

60
                while ($context->getBlockParser()->next("~^>(?: | ([ \\t]{1,$spaces} | :) (.*))$~mAx", $nextMatches, $nextOffsets)) {
1✔
61
                        // group 0 always participates in a successful match, but next() cannot type that
62
                        $line = $nextMatches[0] ?? throw new \LogicException('Match without group 0.');
1✔
63
                        $lineOffset = $nextOffsets[0] ?? throw new \LogicException('Match without group 0.');
1✔
64

65
                        $totalLength += strlen($line) + 1; // +1 for \n
1✔
66

67
                        // Track where this line's content starts in absolute terms
68
                        $lineContentOffset = $nextOffsets[2] ?? $lineOffset + 2; // after "> "
1✔
69
                        $lines[] = ['content' => $nextMatches[2] ?? '', 'offset' => $lineContentOffset];
1✔
70
                }
71

72
                // Join content for parsing, but track line boundaries
73
                $content = implode("\n", array_column($lines, 'content'));
1✔
74
                $trimmed = trim($content);
1✔
75

76
                // Parse nested content
77
                $parsed = $context->parseBlock($trimmed);
1✔
78
                if (!$parsed->children) {
1✔
UNCOV
79
                        return null;
×
80
                }
81

82
                // Fix positions in parsed content using offset map
83
                Texy\OffsetMap::fromLines($lines, strlen($content) - strlen(ltrim($content)))
1✔
84
                        ->applyTo($parsed);
1✔
85

86
                return new BlockQuoteNode(
1✔
87
                        $parsed,
1✔
88
                        Texy\Modifier::parse($mMod, $offsets[1] ?? null),
1✔
89
                        new Range($startOffset, $totalLength),
1✔
90
                );
91
        }
92
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc