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

dg / texy / 22262497275

21 Feb 2026 07:01PM UTC coverage: 93.057% (+0.7%) from 92.367%
22262497275

push

github

dg
added CLAUDE.md

2426 of 2607 relevant lines covered (93.06%)

0.93 hits per line

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

89.66
/src/Texy/Modules/ScriptModule.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 function preg_quote, preg_split, trim;
12

13

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

22

23
        public function __construct(Texy\Texy $texy)
1✔
24
        {
25
                $this->texy = $texy;
1✔
26

27
                $texy->addHandler('script', $this->solve(...));
1✔
28

29
                $texy->registerLinePattern(
1✔
30
                        $this->pattern(...),
1✔
31
                        '#\{\{((?:[^' . Texy\Patterns::MARK . '}]++|[}])+)\}\}()#U',
1✔
32
                        'script',
1✔
33
                );
34
        }
1✔
35

36

37
        /**
38
         * Callback for: {{...}}.
39
         * @param  string[]  $matches
40
         */
41
        public function pattern(Texy\LineParser $parser, array $matches): Texy\HtmlElement|string|null
1✔
42
        {
43
                [, $mContent] = $matches;
1✔
44
                // [1] => ...
45

46
                $cmd = trim($mContent);
1✔
47
                if ($cmd === '') {
1✔
48
                        return null;
×
49
                }
50

51
                $raw = null;
1✔
52
                $args = [];
1✔
53
                // function (arg, arg, ...) or function: arg, arg
54
                if ($matches = Texy\Regexp::match($cmd, '#^([a-z_][a-z0-9_-]*)\s*(?:\(([^()]*)\)|:(.*))$#iu')) {
1✔
55
                        $cmd = $matches[1];
1✔
56
                        $raw = trim($matches[3] ?? $matches[2]);
1✔
57
                        if ($raw !== '') {
1✔
58
                                $args = preg_split('#\s*' . preg_quote($this->separator, '#') . '\s*#u', $raw);
1✔
59
                        }
60
                }
61

62
                return $this->texy->invokeAroundHandlers('script', $parser, [$cmd, $args, $raw]);
1✔
63
        }
64

65

66
        /**
67
         * Finish invocation.
68
         * @param ?list<string>  $args
69
         */
70
        private function solve(
1✔
71
                Texy\HandlerInvocation $invocation,
72
                string $cmd,
73
                ?array $args = null,
74
                ?string $raw = null,
75
        ): ?string
76
        {
77
                if ($cmd === 'texy' && $args) {
1✔
78
                        switch ($args[0]) {
1✔
79
                                case 'nofollow':
1✔
80
                                        $this->texy->linkModule->forceNoFollow = true;
×
81
                                        break;
×
82
                        }
83

84
                        return '';
1✔
85
                }
86

87
                return null;
1✔
88
        }
89
}
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