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

dg / texy / 20980727294

14 Jan 2026 03:00AM UTC coverage: 92.376%. Remained the same
20980727294

push

github

dg
added CLAUDE.md

2387 of 2584 relevant lines covered (92.38%)

0.92 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
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
declare(strict_types=1);
9

10
namespace Texy\Modules;
11

12
use Texy;
13
use function preg_quote, preg_split, trim;
14

15

16
/**
17
 * Scripts module.
18
 */
19
final class ScriptModule extends Texy\Module
20
{
21
        /** arguments separator */
22
        public string $separator = ',';
23

24

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

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

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

38

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

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

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

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

66

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

85
                        return '';
1✔
86
                }
87

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