• 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

95.83
/src/Texy/Modules/DirectiveModule.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\DirectiveNode;
12
use Texy\ParseContext;
13
use Texy\Range;
14
use Texy\Syntax;
15
use function strlen, trim;
16

17

18
/**
19
 * Processes {{macro}} script commands.
20
 */
21
final class DirectiveModule extends Texy\Module
22
{
23
        public function __construct(
1✔
24
                private Texy\Texy $texy,
25
        ) {
26
                $texy->addHandler('afterParse', $this->processDirectives(...));
1✔
27
        }
1✔
28

29

30
        /**
31
         * Consumes {{texy: ...}} directives: stores document-level options into
32
         * DocumentNode::$meta and removes the directive nodes from the AST, so all
33
         * output generators see the same document.
34
         */
35
        public function processDirectives(Texy\Nodes\DocumentNode $doc): void
1✔
36
        {
37
                (new Texy\NodeTraverser)->traverse($doc, function (Texy\Node $node) use ($doc): ?int {
1✔
38
                        if ($node instanceof DirectiveNode) {
1✔
39
                                $parsed = $node->parseContent();
1✔
40
                                if ($parsed['name'] === 'texy' && $parsed['args']) {
1✔
41
                                        foreach ($parsed['args'] as $arg) {
1✔
42
                                                $doc->meta[$arg] = true;
1✔
43
                                        }
44
                                        return Texy\NodeTraverser::RemoveNode;
1✔
45
                                }
46
                        }
47
                        return null;
1✔
48
                });
1✔
49
        }
1✔
50

51

52
        public function beforeParse(string &$text): void
1✔
53
        {
54
                $this->texy->registerLinePattern(
1✔
55
                        $this->parse(...),
1✔
56
                        '~
1✔
57
                                \{\{
58
                                ((?:
59
                                        [^}]++ |   # content not containing }
60
                                        }          # or single }
61
                                )+)
62
                                }}
63
                        ~Ux',
64
                        Syntax::Directive,
1✔
65
                );
66
        }
1✔
67

68

69
        /**
70
         * Parses {{macro}}.
71
         * @param  array{string, string}  $matches
72
         * @param  array{int, int}  $offsets
73
         */
74
        public function parse(ParseContext $context, array $matches, array $offsets): ?DirectiveNode
1✔
75
        {
76
                return trim($matches[1]) === ''
1✔
UNCOV
77
                        ? null
×
78
                        : new DirectiveNode($matches[1], new Range($offsets[0], strlen($matches[0])));
1✔
79
        }
80
}
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