Skip to content

Commit 9bc8130

Browse files
committed
[BUGFIX] Reset section stack for the next document
Resolves #1093
1 parent ded7664 commit 9bc8130

File tree

6 files changed

+26
-150
lines changed

6 files changed

+26
-150
lines changed

packages/guides/src/Compiler/NodeTransformers/SectionCreationTransformer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ final class SectionCreationTransformer implements NodeTransformer
3434

3535
public function enterNode(Node $node, CompilerContextInterface $compilerContext): Node
3636
{
37+
if ($node instanceof DocumentNode) {
38+
$this->sectionStack = [];
39+
}
40+
3741
if (!$compilerContext->getShadowTree()->getParent()?->getNode() instanceof DocumentNode) {
3842
return $node;
3943
}

tests/Integration/tests-full/markdown-full/default-menu-md/expected/anotherPage.html

Lines changed: 7 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html class="no-js" lang="en">
33
<head>
4-
<title>Another Page - Bootstrap Theme</title>
4+
<title>Another Page</title>
55
<!-- Required meta tags -->
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -19,22 +19,7 @@
1919
<span class="navbar-toggler-icon"></span>
2020
</button>
2121
<div class="collapse navbar-collapse" id="navbarSupportedContent">
22-
23-
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
24-
<li class="nav-item">
25-
<a href="/anotherPage.html" class="nav-link current active" aria-current="page">
26-
Another Page
27-
</a>
28-
</li><li class="nav-item">
29-
<a href="/somePage.html" class="nav-link">
30-
Some Page
31-
</a>
32-
</li><li class="nav-item">
33-
<a href="/yetAnotherPage.html" class="nav-link">
34-
Yet Another Page
35-
</a>
36-
</li></ul>
37-
22+
3823
</div>
3924
</div>
4025
</nav>
@@ -44,35 +29,18 @@
4429
<div class="container">
4530
<div class="row">
4631
<div class="col-lg-3">
47-
<nav class="nav flex-column">
48-
<ul class="menu-level-main">
49-
<li>
50-
<a href="/anotherPage.html"
51-
class="nav-link current active" aria-current="page">Another Page</a>
52-
</li>
53-
<li>
54-
<a href="/somePage.html"
55-
class="nav-link">Some Page</a>
56-
</li>
57-
<li>
58-
<a href="/yetAnotherPage.html"
59-
class="nav-link">Yet Another Page</a>
60-
</li>
61-
</ul>
62-
</nav>
63-
32+
6433
</div>
6534
<div class="col-lg-9">
6635

6736
<nav aria-label="breadcrumb">
6837
<ol class="breadcrumb">
69-
<li class="breadcrumb-item"><a href="/index.html">Document Title</a></li>
70-
<li class="breadcrumb-item"><a href="/anotherPage.html">Another Page</a></li>
38+
<li class="breadcrumb-item"><a href="index.html">Document Title</a></li>
39+
<li class="breadcrumb-item"><a href="#">Another Page</a></li>
7140
</ol>
7241
</nav>
7342
<!-- content start -->
74-
75-
<div class="section" id="another-page">
43+
<div class="section" id="another-page">
7644
<h1>Another Page</h1>
7745

7846
<p>Lorem Ipsum Dolor.</p>
@@ -84,14 +52,7 @@ <h1>Another Page</h1>
8452
</div>
8553
</div>
8654
</main>
87-
<footer class="bg-primary text-light">
88-
<div class="container">
89-
90-
<p>Generated by <a href="https://www.phpdoc.org/">phpDocumentor</a>.</p>
91-
92-
</div>
93-
</footer>
94-
55+
9556
<!-- Optional JavaScript; choose one of the two! -->
9657

9758
<!-- Option 1: Bootstrap Bundle with Popper -->

tests/Integration/tests-full/markdown-full/default-menu-md/expected/index.html

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html class="no-js" lang="en">
33
<head>
4-
<title>Document Title - Bootstrap Theme</title>
4+
<title>Document Title</title>
55
<!-- Required meta tags -->
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -19,22 +19,7 @@
1919
<span class="navbar-toggler-icon"></span>
2020
</button>
2121
<div class="collapse navbar-collapse" id="navbarSupportedContent">
22-
23-
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
24-
<li class="nav-item">
25-
<a href="/anotherPage.html" class="nav-link">
26-
Another Page
27-
</a>
28-
</li><li class="nav-item">
29-
<a href="/somePage.html" class="nav-link">
30-
Some Page
31-
</a>
32-
</li><li class="nav-item">
33-
<a href="/yetAnotherPage.html" class="nav-link">
34-
Yet Another Page
35-
</a>
36-
</li></ul>
37-
22+
3823
</div>
3924
</div>
4025
</nav>
@@ -44,54 +29,29 @@
4429
<div class="container">
4530
<div class="row">
4631
<div class="col-lg-3">
47-
<nav class="nav flex-column">
48-
<ul class="menu-level-main">
49-
<li>
50-
<a href="/anotherPage.html"
51-
class="nav-link">Another Page</a>
52-
</li>
53-
<li>
54-
<a href="/somePage.html"
55-
class="nav-link">Some Page</a>
56-
</li>
57-
<li>
58-
<a href="/yetAnotherPage.html"
59-
class="nav-link">Yet Another Page</a>
60-
</li>
61-
</ul>
62-
</nav>
63-
32+
6433
</div>
6534
<div class="col-lg-9">
6635

6736
<nav aria-label="breadcrumb">
6837
<ol class="breadcrumb">
69-
<li class="breadcrumb-item"><a href="/index.html">Document Title</a></li>
38+
<li class="breadcrumb-item"><a href="#">Document Title</a></li>
7039
</ol>
7140
</nav>
7241
<!-- content start -->
73-
74-
<div class="section" id="document-title">
42+
<div class="section" id="document-title">
7543
<h1>Document Title</h1>
7644

7745
<p>Lorem Ipsum Dolor.</p>
7846

79-
8047
</div>
8148
<!-- content end -->
8249
</div>
8350
</div>
8451
</div>
8552
</div>
8653
</main>
87-
<footer class="bg-primary text-light">
88-
<div class="container">
89-
90-
<p>Generated by <a href="https://www.phpdoc.org/">phpDocumentor</a>.</p>
91-
92-
</div>
93-
</footer>
94-
54+
9555
<!-- Optional JavaScript; choose one of the two! -->
9656

9757
<!-- Option 1: Bootstrap Bundle with Popper -->

tests/Integration/tests-full/markdown-full/default-menu-md/expected/somePage.html

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html class="no-js" lang="en">
33
<head>
4-
<title>Some Page - Bootstrap Theme</title>
4+
<title>Some Page</title>
55
<!-- Required meta tags -->
66
<meta charset="utf-8">
77
<meta name="viewport" content="width=device-width, initial-scale=1">
@@ -19,22 +19,7 @@
1919
<span class="navbar-toggler-icon"></span>
2020
</button>
2121
<div class="collapse navbar-collapse" id="navbarSupportedContent">
22-
23-
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
24-
<li class="nav-item">
25-
<a href="/anotherPage.html" class="nav-link">
26-
Another Page
27-
</a>
28-
</li><li class="nav-item">
29-
<a href="/somePage.html" class="nav-link current active" aria-current="page">
30-
Some Page
31-
</a>
32-
</li><li class="nav-item">
33-
<a href="/yetAnotherPage.html" class="nav-link">
34-
Yet Another Page
35-
</a>
36-
</li></ul>
37-
22+
3823
</div>
3924
</div>
4025
</nav>
@@ -44,38 +29,21 @@
4429
<div class="container">
4530
<div class="row">
4631
<div class="col-lg-3">
47-
<nav class="nav flex-column">
48-
<ul class="menu-level-main">
49-
<li>
50-
<a href="/anotherPage.html"
51-
class="nav-link">Another Page</a>
52-
</li>
53-
<li>
54-
<a href="/somePage.html"
55-
class="nav-link current active" aria-current="page">Some Page</a>
56-
</li>
57-
<li>
58-
<a href="/yetAnotherPage.html"
59-
class="nav-link">Yet Another Page</a>
60-
</li>
61-
</ul>
62-
</nav>
63-
32+
6433
</div>
6534
<div class="col-lg-9">
6635

6736
<nav aria-label="breadcrumb">
6837
<ol class="breadcrumb">
69-
<li class="breadcrumb-item"><a href="/index.html">Document Title</a></li>
70-
<li class="breadcrumb-item"><a href="/somePage.html">Some Page</a></li>
38+
<li class="breadcrumb-item"><a href="index.html">Document Title</a></li>
39+
<li class="breadcrumb-item"><a href="#">Some Page</a></li>
7140
</ol>
7241
</nav>
7342
<!-- content start -->
74-
75-
<div class="section" id="some-page">
43+
<div class="section" id="some-page">
7644
<h1>Some Page</h1>
7745

78-
<p>Lorem Ipsum <span class="custom">Dolor</span>.</p>
46+
<p>Lorem Ipsum <code>Dolor</code>.</p>
7947

8048
</div>
8149
<!-- content end -->
@@ -84,14 +52,7 @@ <h1>Some Page</h1>
8452
</div>
8553
</div>
8654
</main>
87-
<footer class="bg-primary text-light">
88-
<div class="container">
89-
90-
<p>Generated by <a href="https://www.phpdoc.org/">phpDocumentor</a>.</p>
91-
92-
</div>
93-
</footer>
94-
55+
9556
<!-- Optional JavaScript; choose one of the two! -->
9657

9758
<!-- Option 1: Bootstrap Bundle with Popper -->

tests/Integration/tests-full/markdown-full/default-menu-md/input/skip

Lines changed: 0 additions & 4 deletions
This file was deleted.

tests/Integration/tests/markdown/link-page-md/expected/subpages/index.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<!-- content start -->
2-
<div class="section" id="page-1">
3-
<h1>Page 1</h1>
4-
5-
<p>This is a Markdown document with some basic formatting.</p>
6-
7-
</div>
8-
<div class="section" id="markdown-with-links">
2+
<div class="section" id="markdown-with-links">
93
<h1>Markdown with links</h1>
104

115
<p>This is a Markdown document with some basic formatting.</p>

0 commit comments

Comments
 (0)