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

dg / texy / 42887648368

10 Nov 2026 01:51PM UTC coverage: 96.622% (-0.1%) from 96.735%
42887648368

push

github

dg
Config::$locales: each locale is a list of four quotes (BC break)

Opening and closing double quotes, then the single ones, instead of the pairs
singleQuotes and doubleQuotes. The compatibility layer converts the old table.

cabae8f0-9dec-45ab-a919-45e6dadc3ad6

8 of 8 new or added lines in 3 files covered. (100.0%)

73 existing lines in 18 files now uncovered.

3719 of 3849 relevant lines covered (96.62%)

0.97 hits per line

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

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

3
/**
4
 * This file is part of the Texy! (https://texy.deegee.dev)
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\Parsing\ParseContext;
13
use Texy\{Range, Syntax};
14
use function strlen;
15

16

17
/**
18
 * Processes blockquote syntax with nested content.
19
 */
20
final class BlockQuoteModule extends Texy\Module
21
{
22
        public function register(Texy\Parsing\Registry $registry): void
23
        {
24
                $registry->addBlock(
1 ✔
25
                        Syntax::Blockquote,
1 ✔
26
                        '~^
27
                                (?: ' . Texy\Patterns::ModifierHAlign . '\n)? # modifier (1)
1 ✔
28
                                >                                      # blockquote char
29
                                ( [ \t]++ | : )                        # space/tab or colon (2)
30
                                ( \S.*+ )                              # content (3)
31
                        $~mUx',
32
                        $this->parse(...),
1 ✔
33
                );
34
        }
1 ✔
35

36

37
        /**
38
         * Parses blockquote.
39
         * @param  array{string, ?string, string, string}  $matches
40
         * @param  array{int, ?int, int, int}  $offsets
41
         */
42
        public function parse(ParseContext $context, array $matches, array $offsets): ?BlockQuoteNode
43
        {
44
                [, $mMod, $mPrefix, $mContent] = $matches;
1 ✔
45

46
                $startOffset = $offsets[0];
1 ✔
47
                $totalLength = strlen($matches[0]);
1 ✔
48

49
                // Collect lines with their absolute offsets
50
                $lines = [['content' => $mContent, 'offset' => $offsets[3]]];
1 ✔
51
                $spaces = max(1, strlen($mPrefix));
1 ✔
52

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

58
                        $totalLength += strlen($line) + 1; // +1 for \n
1 ✔
59

60
                        // Track where this line's content starts in absolute terms
61
                        $lineContentOffset = $nextOffsets[2] ?? $lineOffset + 2; // after "> "
1 ✔
62
                        $lines[] = ['content' => $nextMatches[2] ?? '', 'offset' => $lineContentOffset];
1 ✔
63
                }
64

65
                // Join content for parsing, but track line boundaries
66
                $content = implode("\n", array_column($lines, 'content'));
1 ✔
67
                $trimmed = trim($content);
1 ✔
68

69
                // Parse nested content
70
                $parsed = $context->parseBlock($trimmed);
1 ✔
71
                if (!$parsed->children) {
1 ✔
UNCOV
72
                        return null;
×
73
                }
74

75
                // Fix positions in parsed content using offset map
76
                Texy\Parsing\OffsetMap::fromLines($lines, strlen($content) - strlen(ltrim($content)))
1 ✔
77
                        ->applyTo($parsed);
1 ✔
78

79
                return new BlockQuoteNode(
1 ✔
80
                        $parsed,
81
                        Texy\Modifier::parse($mMod, $offsets[1] ?? null),
1 ✔
82
                        new Range($startOffset, $totalLength),
1 ✔
83
                );
84
        }
85
}
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