Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/TagEngine.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,9 @@ protected function setRegex(): void

// Tag with content pattern: <c-tag attributes>content</c-tag>
$contentOpen = "<$prefix-$tagName$whitespace$attributes>";
$contentInner = '(.*?)'; // Non-greedy content between tags
// Recurse through nested custom tags so a closing tag always belongs to
// the opening tag at the current nesting level.
$contentInner = '((?:(?R)|(?!<\/' . $prefix . '-\\3>).)*)';
$contentClose = "<\/$prefix-\\3>"; // Closing tag, referencing the tag name from group 3
$contentPattern = "$contentOpen$contentInner$contentClose";

Expand Down
19 changes: 4 additions & 15 deletions tests/TagEngine/CustomTagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,10 @@ public function testTagWithInnerContentNested(): void
</div>
HTML;
$result = $this->tagEngine->parse($element);
$expected = <<<HTML
<div class="outer">
This is a render from a plugin tag

Outer Content
<div class="inner">
Inner Content
<c-github>
Inner Inner Content

</div>
</c-github>
</div>
HTML;
$this->assertSame($expected, $result);

$this->assertStringNotContainsString('<c-github>', $result);
$this->assertSame(2, substr_count($result, 'This is a render from a plugin tag'));
$this->assertStringContainsString('Inner Inner Content', $result);
}

/**
Expand Down
8 changes: 3 additions & 5 deletions tests/TagEngine/NestedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,9 @@ public function testTagsNested(): void
{
$element = '<c-github><c-github></c-github></c-github>';
$result = $this->tagEngine->parse($element);
$expected = <<<HTML
This is a render from a plugin tag
<c-github></c-github>
HTML;
$this->assertSame($expected, $result);

$this->assertStringNotContainsString('<c-github>', $result);
$this->assertSame(2, substr_count($result, 'This is a render from a plugin tag'));
}

/**
Expand Down
5 changes: 4 additions & 1 deletion tests/TagEngine/TagEngineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,10 @@ public function testThrowsRegexException(): void
try {
$instance->parse($test);
} catch (RegexException $e) {
$this->assertEquals('Backtrack limit was exhausted', $e->getMessage());
$this->assertContains(
$e->getMessage(),
['Backtrack limit was exhausted', 'JIT stack limit exhausted'],
);
$this->assertNotEmpty($e->getRegex());
$this->assertNotEmpty($e->getSource());
}
Expand Down