Skip to content

Commit

Permalink
fix(documentator): Preprocessor regexp to find instruction when `<t…
Browse files Browse the repository at this point in the history
…arget "value">`.

Origin: 32e0d3b
  • Loading branch information
LastDragon-ru committed Jul 13, 2024
1 parent a0aba35 commit 16686b9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/documentator/src/Preprocessor/Preprocessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Preprocessor {
protected const Regexp = <<<'REGEXP'
/^
(?P<expression>
\[(?P<instruction>[^\]=]+)(?:=[^]]+)?\]:\s(?P<target>(?:[^ ]+?)|(?:<[^>]+?>))
\[(?P<instruction>[^\]=]+)(?:=[^]]+)?\]:\s+(?P<target>(?:[^<][^ ]+?)|(?:<[^>]+?>))
(?P<pBlock>\s(?:\(|(?P<pStart>['"]))(?P<parameters>.+?)(?:\)|(?P=pStart)))?
)
(?P<content>\R
Expand Down Expand Up @@ -141,7 +141,7 @@ public function process(string $path, string $string): string {
callback: function (array $matches) use (&$cache, $path): string {
// Hash
$instruction = $this->getInstruction($matches['instruction']);
$target = $matches['target'];
$target = trim($matches['target']);
$target = str_starts_with($target, '<') && str_ends_with($target, '>')
? mb_substr($target, 1, -1)
: rawurldecode($target);
Expand Down
8 changes: 4 additions & 4 deletions packages/documentator/src/Preprocessor/PreprocessorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public function testProcess(): void {
[unknown]: ./path/to/file
[empty]: ./path/to/file
[empty]: <./path/to/file "value">
[processable]: ./path/to/file
Expand Down Expand Up @@ -101,11 +101,11 @@ public function testProcess(): void {
[unknown]: ./path/to/file
[empty]: ./path/to/file
[//]: # (start: 8619b6a617a04e2b1ed8916cd29b8e9947a9157ffdef8d2e8a51fe60fbc13948)
[empty]: <./path/to/file "value">
[//]: # (start: 99c91ec6684e9a6f1353966bb4f72dd70ab4241618b106ef24da7cbaeb5dbfab)
[//]: # (warning: Generated automatically. Do not edit.)
[//]: # (empty)
[//]: # (end: 8619b6a617a04e2b1ed8916cd29b8e9947a9157ffdef8d2e8a51fe60fbc13948)
[//]: # (end: 99c91ec6684e9a6f1353966bb4f72dd70ab4241618b106ef24da7cbaeb5dbfab)
[processable]: ./path/to/file
[//]: # (start: 378a07bc67ecbe88f5d2f642e70681461f61d3f2f5e83379015b879110c83947)
Expand Down

0 comments on commit 16686b9

Please sign in to comment.