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

dg / texy / 22262589061

21 Feb 2026 07:04PM UTC coverage: 92.991% (+1.8%) from 91.178%
22262589061

push

github

dg
LinkModule: deprecated label and modifiers in link definitions

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

126 existing lines in 22 files now uncovered.

2083 of 2240 relevant lines covered (92.99%)

0.93 hits per line

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

90.0
/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\Regexp;
12
use function trim;
13

14

15
/**
16
 * Processes {{macro}} script commands.
17
 */
18
final class DirectiveModule extends Texy\Module
19
{
20
        /** arguments separator */
21
        public string $separator = ',';
22

23

24
        public function __construct(
1✔
25
                private Texy\Texy $texy,
26
        ) {
27
                $texy->addHandler('script', $this->solve(...));
1✔
28
        }
1✔
29

30

31
        public function beforeParse(string &$text): void
1✔
32
        {
33
                $this->texy->registerLinePattern(
1✔
34
                        $this->parse(...),
1✔
35
                        '~
36
                                \{\{
37
                                ((?:
38
                                        [^' . Texy\Patterns::MARK . '}]++ |  # content not containing }
1✔
39
                                        }                                    # or single }
40
                                )+)
41
                                }}
42
                        ~U',
43
                        'script',
1✔
44
                );
45
        }
1✔
46

47

48
        /**
49
         * Parses {{...}}
50
         * @param  array<?string>  $matches
51
         */
52
        public function parse(Texy\InlineParser $parser, array $matches): Texy\HtmlElement|string|null
1✔
53
        {
54
                [, $mContent] = $matches;
1✔
55
                // [1] => ...
56

57
                $cmd = trim($mContent);
1✔
58
                if ($cmd === '') {
1✔
UNCOV
59
                        return null;
×
60
                }
61

62
                $raw = null;
1✔
63
                $args = [];
1✔
64
                // function (arg, arg, ...) or function: arg, arg
65
                if ($matches = Regexp::match($cmd, '~^ ([a-z_][a-z0-9_-]*) \s* (?: \( ([^()]*) \) | : (.*) )$~i')) {
1✔
66
                        $cmd = $matches[1];
1✔
67
                        $raw = trim($matches[3] ?? $matches[2]);
1✔
68
                        if ($raw !== '') {
1✔
69
                                $args = Regexp::split($raw, '~\s*' . Regexp::quote($this->separator) . '\s*~');
1✔
70
                        }
71
                }
72

73
                return $this->texy->invokeAroundHandlers('script', $parser, [$cmd, $args, $raw]);
1✔
74
        }
75

76

77
        /**
78
         * Finish invocation.
79
         * @param ?list<string>  $args
80
         */
81
        private function solve(
1✔
82
                Texy\HandlerInvocation $invocation,
83
                string $cmd,
84
                ?array $args = null,
85
                ?string $raw = null,
86
        ): ?string
87
        {
88
                if ($cmd === 'texy' && $args) {
1✔
89
                        switch ($args[0]) {
1✔
90
                                case 'nofollow':
1✔
UNCOV
91
                                        $this->texy->linkModule->forceNoFollow = true;
×
UNCOV
92
                                        break;
×
93
                        }
94

95
                        return '';
1✔
96
                }
97

98
                return null;
1✔
99
        }
100
}
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