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

dg / texy / 21345344909

26 Jan 2026 03:32AM UTC coverage: 92.382% (-0.4%) from 92.744%
21345344909

push

github

dg
HtmlElement: removed toHtml() & toText()

18 of 19 new or added lines in 5 files covered. (94.74%)

149 existing lines in 21 files now uncovered.

2401 of 2599 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 Texy\Regexp;
14
use function preg_quote, preg_split, trim;
15

16

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

25

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

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

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

46

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

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

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

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

75

76
        public function toElement(
1✔
77
                Texy\HandlerInvocation $invocation,
78
                string $cmd,
79
                ?array $args = null,
80
                ?string $raw = null,
81
        ): ?string
82
        {
83
                if ($cmd === 'texy' && $args) {
1✔
84
                        switch ($args[0]) {
1✔
85
                                case 'nofollow':
1✔
86
                                        $this->texy->linkModule->forceNoFollow = true;
×
UNCOV
87
                                        break;
×
88
                        }
89

90
                        return '';
1✔
91
                }
92

93
                return null;
1✔
94
        }
95
}
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